Skip to content

fix(secret): add create; update of absent is 404 - #1708

Merged
retr0h merged 1 commit into
mainfrom
fix/update-of-absent-is-404
Nov 28, 2026
Merged

retr0h merged 1 commit into
mainfrom
fix/update-of-absent-is-404

Conversation

@retr0h

@retr0h retr0h commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Specs: osapi-io/specs#708

CONTRIBUTING says that one endpoint does not both create and update, that a POST creates with the name in the body, and that an update of a thing that is absent is an error. file update and secret update both created. This change keeps no backward compatibility.

File

  • PUT /api/file/{name} of a name that is not there is 404. file upload is the create. The same content answers changed: false, and never 201.

Secret

  • New POST /api/secret/{vault}, with {"key": "...", "value": "..."}. It is osapi client secret create, SDK Secret.Create and UI operation PostSecret. It writes version 1, and answers 201 with Location: /api/secret/{vault}/{key}.
    • Create on an existing key always conflicts: it is 409. Create finds the key in the list of the vault and reads no value.
  • PUT /api/secret/{vault}/{key} of a key that is not there is 404. Its body stays SecretUpdateRequest.
  • Create lists the keys, then writes. The vault interface has no write that only creates, so two creates of one new key at the same time can both write. The specs page says so.

The DSL

  • Location takes several output fields, joined by / and path-escaped. The DSL spec term (osapi dsl endpoint spec) and internal/dslcheck/testdata/strings.txt say so.

Other changes in this PR

  • Generated: the CLI command and pages, the API pages, the SDK, the UI client, the catalog and the internal/apicontract golden.
  • The UI Secrets page writes with PUT for a key in the list, and with POST for a new key.
  • Integration: the sealed-secret scenario and TestAuditOfAWrite write with create. The DSL examples run create, then update.
  • Prose: the secrets page and the two agent skills say create.
  • osapi-lab: fix(controller): create a missing signing key osapi-lab#112 writes a missing signing key with create. Merge it right after this PR.

Checks

  • go test -cover: secret, file, endpoint and endpoint/server at 100%. apicontract, dslcheck, skills, cmd, pkg/sdk and the integration unit gate pass.
  • golangci-lint run: 0 issues.
  • UI: react-typecheck, react-lint, react-fmt-check, react-unit (107 pass) and react-build pass.
  • Docs: docs-build, docs-fmt-check and md-fmt-check pass.
  • Integration with OSAPI_INTEGRATION_WRITES=1, for cli and sdk, on head aef7cf2's code:

UI click-through, for a person who is signed in. On Secrets:

  1. Write a new key. The key shows, at version 1.
  2. Write the same key with a new value. It goes to version 2.
  3. Delete a key in a different tab, then write it. A 404 message shows.

Closes #1666

🤖 Generated with Claude Code

@retr0h
retr0h force-pushed the fix/update-of-absent-is-404 branch 2 times, most recently from c4a76bb to 30c9916 Compare November 27, 2026 22:40
@retr0h
retr0h marked this pull request as ready for review November 27, 2026 22:40
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1708   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         446      446           
  Lines       25257    25281   +24     
=======================================
+ Hits        25256    25280   +24     
  Misses          1        1           
Files with missing lines Coverage Δ
internal/controller/endpoint/endpoint.go 100.00% <100.00%> (ø)
internal/controller/endpoint/openapi.go 100.00% <100.00%> (ø)
internal/controller/endpoint/server/server.go 100.00% <100.00%> (ø)
internal/controller/endpoint/validate.go 100.00% <100.00%> (ø)
internal/controller/endpoints/file/methods.go 100.00% <100.00%> (ø)
internal/controller/endpoints/secret/methods.go 100.00% <100.00%> (ø)
internal/controller/endpoints/secret/samples.go 100.00% <100.00%> (ø)
internal/controller/endpoints/secret/secret.go 100.00% <ø> (ø)
pkg/sdk/client/file_upload.go 100.00% <ø> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a8de90...aef7cf2. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@retr0h
retr0h force-pushed the fix/update-of-absent-is-404 branch from dae7a5d to 3ea1140 Compare November 28, 2026 01:11
@retr0h retr0h added the needs-standards-review The author asks for the independent standards review label Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Standards review: changes requested (3). (GitHub refuses a formal "request changes" on a PR by the same account, so this is a comment.)

  1. internal/controller/endpoints/secret/methods_public_test.go, TestCreate (the new method). The loop picks its checks with a switch on want200, wantErr and wantText fields. Rule: tables use validateFunc (CONTRIBUTING.md Test file conventions). Give each row a validateFunc(got secret.Info, err error). TestUpdate has the same shape and the PR extends it with wantErr/wantText; use validateFunc there too.
  2. Same file, TestCreate row 1: s.Equal("ops@example.com", vault.Actor(ctx), "the vault records who"). Custom assertion message. Rule: no custom assertion messages. Put the intent in the row name.
  3. Commit subject "fix(file,secret): an update of a thing that is not there is a 404, and secret create makes a key" is 96 characters. Rule: 50 or fewer.

Conforms: the specs PR is linked (specs#708) and the lab PR is named; the compare of secrets is constant-time; the error text does not hold the value (NotContains(err, "s3cret")); the new route has integration cases and an authorization case; both skills and the UI are updated; Location takes several fields in the DSL, with the DSL spec term and strings.txt updated; imports keep three groups.

@retr0h retr0h removed the needs-standards-review The author asks for the independent standards review label Nov 28, 2026
@retr0h retr0h changed the title fix(file,secret): an update of a thing that is not there is a 404, and secret create makes a key fix(file,secret): update of absent is 404 Nov 28, 2026
@retr0h
retr0h force-pushed the fix/update-of-absent-is-404 branch from 3ea1140 to 5bf9936 Compare November 28, 2026 01:15
@retr0h retr0h added the needs-standards-review The author asks for the independent standards review label Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Standards review: still changes requested (3 open of the 3). The head moved to 5bf9936, but items 1 and 2 are unchanged: TestCreate still picks its checks with a switch on want200, wantErr and wantText instead of a validateFunc, and s.Equal("ops@example.com", vault.Actor(ctx), "the vault records who") still has a custom message. The new title, "fix(file,secret): update of absent is 404", is under 50 characters, but it no longer names the secret create that the PR adds; the squash subject should say both.

@retr0h retr0h added needs-code-review The author asks for the independent code review and removed needs-standards-review The author asks for the independent standards review labels Nov 28, 2026
@retr0h retr0h changed the title fix(file,secret): update of absent is 404 fix(secret): add create; update of absent is 404 Nov 28, 2026
@retr0h
retr0h force-pushed the fix/update-of-absent-is-404 branch from 5bf9936 to d927403 Compare November 28, 2026 01:18
@retr0h retr0h added the needs-standards-review The author asks for the independent standards review label Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Standards review: still changes requested (2). The head moved to d927403, but the test file is unchanged: TestCreate still picks its checks with a switch on want200, wantErr and wantText instead of a validateFunc, and s.Equal("ops@example.com", vault.Actor(ctx), "the vault records who") still has a custom message. The title is 48 characters now, which closes the subject item; squash with the title, since the commit is still 96 characters.

@retr0h retr0h removed the needs-standards-review The author asks for the independent standards review label Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Standards review reply: head d927403 has the fixes.

  • git show d927403:internal/controller/endpoints/secret/methods_public_test.go | grep -c 'want200\|the vault records who' prints 0. TestCreate and TestUpdate give each row a validateFunc(got secret.Info, err error). The actor is checked through got.By, which the vault sets from vault.Actor(ctx).
  • The commit subject is fix(secret): add create; update of absent is 404, which is 48 characters: git log -1 --format=%s d927403.

Please check again.

@retr0h retr0h added needs-standards-review The author asks for the independent standards review and removed needs-standards-review The author asks for the independent standards review labels Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Code review: changes requested. Everything except one point checked out (file update 404 on a missing name, secret update 404 on a missing key, Location with several path-escaped fields, the create route and its generated surfaces). One finding is held outside this thread and sent to the maintainer directly, because of what it touches; it is in the secret create handler and will be relayed with a fix.

@retr0h retr0h removed the needs-code-review The author asks for the independent code review label Nov 28, 2026
CONTRIBUTING says one endpoint does not both create and update, a POST
creates with the name in the body, and an update of a thing that is absent
is an error. file update and secret update both created.

- PUT /api/file/{name} of a name that is not there is 404. file upload is
  the create. The same content answers changed false, never 201.
- POST /api/secret/{vault} with {key, value} (osapi client secret create,
  SDK Secret.Create) makes a key as version 1: 201 with a Location header.
  Create on an existing key always conflicts: 409, from the list of the
  vault's keys.
- PUT /api/secret/{vault}/{key} of a key that is not there is 404.
- Location takes several fields, joined by / and escaped, so the secret's
  is /api/secret/{vault}/{key}. The DSL term and dslcheck say so.
- The UI writes a key in the list with PUT and a new key with POST.
- The integration scenario and the audit test write with create. The
  generated CLI, pages, SDK, UI client, catalog and contract golden are
  regenerated. The secrets page and the agent skills say create.

Closes #1666

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h
retr0h force-pushed the fix/update-of-absent-is-404 branch from d927403 to aef7cf2 Compare November 28, 2026 01:59
@retr0h retr0h added needs-code-review The author asks for the independent code review needs-standards-review The author asks for the independent standards review standards-reviewed An independent reviewer checked this PR against the standards code-reviewed An independent reviewer checked correctness, bugs and edge cases and removed needs-standards-review The author asks for the independent standards review needs-code-review The author asks for the independent code review labels Nov 28, 2026
@retr0h

retr0h commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

fixed: an existing key always conflicts

@retr0h
retr0h merged commit 221e017 into main Nov 28, 2026
35 checks passed
@retr0h
retr0h deleted the fix/update-of-absent-is-404 branch November 28, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviewed An independent reviewer checked correctness, bugs and edge cases kind/docs kind/go kind/ts kind/yaml standards-reviewed An independent reviewer checked this PR against the standards test/unit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file update and secret update create a thing that is absent, against the rule that an update of an absent thing is an error

1 participant