Skip to content

Commit 4645ab9

Browse files
committed
chore(api): adapt to main after rebase (writeProjectError arity, apispec API, regen)
Rebased onto main, which landed several changes that intersect this branch: - writeProjectError is now 3-arg (status derived from project.Error.Kind); the get handler's degenerate-GetResult guard now calls the 3-arg form. - apispec.Spec dropped its YAML() method; add apispec.Embedded() returning the raw embedded bytes, used by the generator's drift + route-parity tests. - #62 removed Runtime/Reactions/ReactionConfig from the project types, so the regenerated openapi.yaml (and frontend schema.d.ts) drop those, and the dead ReactionConfig entry is removed from the schema-name map. - CI go.yml: keep main's new golangci-lint `lint` job alongside the gen-verify job, both reading the Go version from go.mod. go build/vet/test all pass; spec + TS regenerate with no drift; gofmt clean.
1 parent 61e69fb commit 4645ab9

7 files changed

Lines changed: 10 additions & 63 deletions

File tree

backend/internal/httpd/apispec/apispec.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ func New(yamlBytes []byte) (*Spec, error) {
6464
return &Spec{doc: doc}, nil
6565
}
6666

67+
// Embedded returns the raw bytes of the committed, embedded openapi.yaml. The
68+
// code-first generator's drift and route-parity tests compare against it
69+
// (specgen.Build() must equal these bytes); ServeYAML writes the same bytes.
70+
func Embedded() []byte { return openapiYAML }
71+
6772
// Operation returns the spec slice for a single (method, path) pair, ready
6873
// to be JSON-serialised. The slice is the OpenAPI Operation object (the
6974
// inner block under e.g. paths./projects.get), with parent path-level

backend/internal/httpd/apispec/openapi.yaml

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,8 @@ components:
314314
type: string
315315
path:
316316
type: string
317-
reactions:
318-
additionalProperties:
319-
$ref: '#/components/schemas/ReactionConfig'
320-
type: object
321317
repo:
322318
type: string
323-
runtime:
324-
type: string
325319
scm:
326320
$ref: '#/components/schemas/SCMConfig'
327321
tracker:
@@ -358,30 +352,6 @@ components:
358352
required:
359353
- project
360354
type: object
361-
ReactionConfig:
362-
properties:
363-
action:
364-
type: string
365-
auto:
366-
type:
367-
- "null"
368-
- boolean
369-
escalateAfter: {}
370-
includeSummary:
371-
type:
372-
- "null"
373-
- boolean
374-
message:
375-
type: string
376-
priority:
377-
type: string
378-
retries:
379-
type:
380-
- "null"
381-
- integer
382-
threshold:
383-
type: string
384-
type: object
385355
ReloadResult:
386356
properties:
387357
degradedCount:
@@ -465,16 +435,6 @@ components:
465435
type:
466436
- "null"
467437
- string
468-
reactions:
469-
additionalProperties:
470-
$ref: '#/components/schemas/ReactionConfig'
471-
type:
472-
- "null"
473-
- object
474-
runtime:
475-
type:
476-
- "null"
477-
- string
478438
scm:
479439
$ref: '#/components/schemas/SCMConfig'
480440
tracker:

backend/internal/httpd/apispec/parity_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestRouteSpecParity(t *testing.T) {
4848
var doc struct {
4949
Paths map[string]map[string]yaml.Node `yaml:"paths"`
5050
}
51-
if err := yaml.Unmarshal(apispec.Default().YAML(), &doc); err != nil {
51+
if err := yaml.Unmarshal(apispec.Embedded(), &doc); err != nil {
5252
t.Fatalf("parse spec: %v", err)
5353
}
5454
httpMethods := map[string]bool{"get": true, "post": true, "put": true, "patch": true, "delete": true}

backend/internal/httpd/apispec/specgen/build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ var schemaNames = map[string]string{
125125
"ProjectTrackerConfig": "TrackerConfig",
126126
"ProjectSCMConfig": "SCMConfig",
127127
"ProjectSCMWebhookConfig": "SCMWebhookConfig",
128-
"ProjectReactionConfig": "ReactionConfig",
129128
}
130129

131130
// markRequestBodyRequired sets requestBody.required: true on the operation's

backend/internal/httpd/apispec/specgen/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestBuild_MatchesEmbedded(t *testing.T) {
1616
if err != nil {
1717
t.Fatalf("Build: %v", err)
1818
}
19-
embedded := apispec.Default().YAML()
19+
embedded := apispec.Embedded()
2020
if !bytes.Equal(got, embedded) {
2121
t.Fatalf("embedded openapi.yaml is stale — run `go generate ./...` and commit.\n"+
2222
"len(fresh)=%d len(embedded)=%d", len(got), len(embedded))

backend/internal/httpd/controllers/projects.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ func (c *ProjectsController) get(w http.ResponseWriter, r *http.Request) {
8787
resp, err := newGetProjectResponse(got)
8888
if err != nil {
8989
// GetResult set neither variant — a Manager-contract violation. Map it
90-
// to a 500 here, before any status/body is written.
91-
writeProjectError(w, r, err, http.StatusInternalServerError)
90+
// to a 500 here, before any status/body is written. A plain error (not
91+
// *project.Error) falls through writeProjectError to a 500 envelope.
92+
writeProjectError(w, r, err)
9293
return
9394
}
9495
envelope.WriteJSON(w, http.StatusOK, resp)

frontend/src/api/schema.d.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ export interface components {
108108
id: string;
109109
name: string;
110110
path: string;
111-
reactions?: {
112-
[key: string]: components["schemas"]["ReactionConfig"];
113-
};
114111
repo: string;
115-
runtime?: string;
116112
scm?: components["schemas"]["SCMConfig"];
117113
tracker?: components["schemas"]["TrackerConfig"];
118114
};
@@ -125,16 +121,6 @@ export interface components {
125121
ProjectResponse: {
126122
project: components["schemas"]["Project"];
127123
};
128-
ReactionConfig: {
129-
action?: string;
130-
auto?: null | boolean;
131-
escalateAfter?: unknown;
132-
includeSummary?: null | boolean;
133-
message?: string;
134-
priority?: string;
135-
retries?: null | number;
136-
threshold?: string;
137-
};
138124
ReloadResult: {
139125
degradedCount: number;
140126
projectCount: number;
@@ -172,10 +158,6 @@ export interface components {
172158
};
173159
UpdateConfigInput: {
174160
agent?: null | string;
175-
reactions?: null | {
176-
[key: string]: components["schemas"]["ReactionConfig"];
177-
};
178-
runtime?: null | string;
179161
scm?: components["schemas"]["SCMConfig"];
180162
tracker?: components["schemas"]["TrackerConfig"];
181163
};

0 commit comments

Comments
 (0)