Skip to content

Commit 1cdc247

Browse files
michaelmcneesclaude
andcommitted
fix: address CodeRabbit review findings
- Remove hardcoded @host localhost:8080 from global API annotations so the spec is served host-agnostic - Add omitempty to StartedAt on ExecutionSummary, ExecutionDetail, and StepSummary to match CompletedAt behaviour and align wire format with schema - Replace http.Error (text/plain) with writeJSONError in budget/usage handlers so 400/500 responses honour the documented ErrorResponse contract; log internal errors via s.Logger instead of leaking details - Pin swag install in CI spec job to v1.16.6 for reproducible builds - Sync govulncheck step with main's known-unfixable exclusion filter - Regenerate swagger.json/yaml Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 593309f commit 1cdc247

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

.github/workflows/engine-ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ jobs:
6060
- name: Install govulncheck
6161
run: go install golang.org/x/vuln/cmd/govulncheck@latest
6262
- name: Run govulncheck
63-
run: govulncheck ./...
63+
run: |
64+
# GO-2026-4887 and GO-2026-4883 are in docker/docker (testcontainers test dep only).
65+
# Fixed in: N/A — no upstream fix available. Remove exclusions when a patched release ships.
66+
OUTPUT=$(govulncheck ./... 2>&1 || true)
67+
echo "$OUTPUT"
68+
ACTIONABLE=$(echo "$OUTPUT" | grep -E '^Vulnerability #[0-9]+:' | grep -vE 'GO-2026-4887|GO-2026-4883')
69+
if [ -n "$ACTIONABLE" ]; then
70+
echo "FAIL: unfixed actionable vulnerabilities found"
71+
exit 1
72+
fi
6473
6574
gosec:
6675
name: Gosec
@@ -84,7 +93,7 @@ jobs:
8493
with:
8594
go-version: '1.25'
8695
- name: Install swag
87-
run: go install github.com/swaggo/swag/cmd/swag@latest
96+
run: go install github.com/swaggo/swag/cmd/swag@v1.16.6
8897
- name: Regenerate spec
8998
run: |
9099
swag init \

packages/engine/internal/server/api.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type ExecutionSummary struct {
2121
Workflow string `json:"workflow"`
2222
Version int `json:"version"`
2323
Status string `json:"status"`
24-
StartedAt *string `json:"started_at"`
24+
StartedAt *string `json:"started_at,omitempty"`
2525
CompletedAt *string `json:"completed_at,omitempty"`
2626
}
2727

@@ -31,7 +31,7 @@ type ExecutionDetail struct {
3131
Workflow string `json:"workflow"`
3232
Version int `json:"version"`
3333
Status string `json:"status"`
34-
StartedAt *string `json:"started_at"`
34+
StartedAt *string `json:"started_at,omitempty"`
3535
CompletedAt *string `json:"completed_at,omitempty"`
3636
Steps []StepSummary `json:"steps"`
3737
}
@@ -41,7 +41,7 @@ type StepSummary struct {
4141
Name string `json:"name"`
4242
Status string `json:"status"`
4343
Error string `json:"error,omitempty"`
44-
StartedAt *string `json:"started_at"`
44+
StartedAt *string `json:"started_at,omitempty"`
4545
CompletedAt *string `json:"completed_at,omitempty"`
4646
}
4747

@@ -512,7 +512,8 @@ func (s *Server) handleListBudgets(w http.ResponseWriter, r *http.Request) {
512512
teamID := auth.TeamIDFromContext(r.Context())
513513
budgets, err := s.BudgetStore.ListTeamBudgets(r.Context(), teamID)
514514
if err != nil {
515-
http.Error(w, err.Error(), http.StatusInternalServerError)
515+
s.Logger.Error("listing budgets", "error", err)
516+
writeJSONError(w, "internal server error", http.StatusInternalServerError)
516517
return
517518
}
518519
writeJSON(w, http.StatusOK, budgets)
@@ -537,19 +538,20 @@ func (s *Server) handleSetBudget(w http.ResponseWriter, r *http.Request) {
537538

538539
var body SetBudgetRequest
539540
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
540-
http.Error(w, "invalid request body", http.StatusBadRequest)
541+
writeJSONError(w, "invalid request body", http.StatusBadRequest)
541542
return
542543
}
543544
if body.Enforcement == "" {
544545
body.Enforcement = "hard"
545546
}
546547
if body.Enforcement != "hard" && body.Enforcement != "warn" {
547-
http.Error(w, "enforcement must be 'hard' or 'warn'", http.StatusBadRequest)
548+
writeJSONError(w, "enforcement must be 'hard' or 'warn'", http.StatusBadRequest)
548549
return
549550
}
550551

551552
if err := s.BudgetStore.SetTeamBudget(r.Context(), teamID, provider, body.MonthlyTokenLimit, body.Enforcement); err != nil {
552-
http.Error(w, err.Error(), http.StatusInternalServerError)
553+
s.Logger.Error("setting budget", "provider", provider, "error", err)
554+
writeJSONError(w, "internal server error", http.StatusInternalServerError)
553555
return
554556
}
555557

@@ -590,7 +592,8 @@ func (s *Server) handleDeleteBudget(w http.ResponseWriter, r *http.Request) {
590592
provider := r.PathValue("provider")
591593

592594
if err := s.BudgetStore.DeleteTeamBudget(r.Context(), teamID, provider); err != nil {
593-
http.Error(w, err.Error(), http.StatusInternalServerError)
595+
s.Logger.Error("deleting budget", "provider", provider, "error", err)
596+
writeJSONError(w, "internal server error", http.StatusInternalServerError)
594597
return
595598
}
596599

@@ -639,7 +642,8 @@ func (s *Server) handleGetUsage(w http.ResponseWriter, r *http.Request) {
639642
usage, err = s.BudgetStore.GetTotalUsage(r.Context(), teamID, period)
640643
}
641644
if err != nil {
642-
http.Error(w, err.Error(), http.StatusInternalServerError)
645+
s.Logger.Error("getting usage", "provider", provider, "error", err)
646+
writeJSONError(w, "internal server error", http.StatusInternalServerError)
643647
return
644648
}
645649

packages/engine/internal/server/docs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// @license.name BSL 1.1
99
// @license.url https://github.com/dvflw/mantle/blob/main/LICENSE
1010
//
11-
// @host localhost:8080
1211
// @basePath /
1312
//
1413
// @securityDefinitions.apikey ApiKeyAuth

packages/engine/internal/server/docs/swagger.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
},
1414
"version": "1.0"
1515
},
16-
"host": "localhost:8080",
1716
"basePath": "/",
1817
"paths": {
1918
"/api/v1/budgets": {

packages/engine/internal/server/docs/swagger.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ definitions:
176176
updated_at:
177177
type: string
178178
type: object
179-
host: localhost:8080
180179
info:
181180
contact:
182181
name: Mantle

0 commit comments

Comments
 (0)