Repository navigation
refactor(stack-kms): make the vendor in backend errors a typed value - #1558
freshtonic wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 30c45f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true |
Mutation testing (cargo-mutants,
|
8f8929d to
538f2f6
Compare
a072f5b to
1d23918
Compare
KeyVendor::name was the one spelling of each vendor, but each vendor client wrote its name again as a string constant. Error::Backend and Error::ZeroKmsOnly took any &'static str, so the Go guest could report an invented vendor, "none". Error::Backend now holds a KeyBackend in the field `backend`, and Error::ZeroKmsOnly holds a KeyVendor. You cannot give these errors a vendor that does not exist. The payload field `vendor` and the message keep the same text, because both come from KeyBackend::name. KeyVendor::from_name reads a name back. The guest config uses it. The guest refused a call to its empty vendor with a backend error that named "none". That call is a routing bug and is not reachable. It is now Error::Unexpected, which has no vendor to name. The Go client kept the names as string literals next to the bytes. It now has one table from byte to name. A new test pins each name and byte to the guest: the guest refuses a name it does not know and a record of another vendor, so a drift on either side fails the test.
538f2f6 to
f9b02c1
Compare
1d23918 to
30c45f2
Compare
|
Folded into #1522 (the typed The plan is |
Summary
Each key vendor client wrote its vendor's name again as a string constant (
"aws-kms", …), althoughKeyVendor::name()is the one spelling. The backend errors took any&'static str, so the Go guest could, and did, report an invented vendor called"none". The Go SDK kept its own copy of the names too. This PR makes the vendor a typed value everywhere, so a name cannot drift or be invented.Changes
stack-kms:Error::Backendnow holdsbackend: KeyBackend(wasvendor: &'static str), andError::ZeroKmsOnlyholds aKeyVendor. NewKeyVendor::from_nameandFrom<KeyVendor> for KeyBackend.KeyVendorfor theirVENDORconstant.from_name.keyVendorNamestable. NewTestKeyVendorNamesMatchTheGuestpins each name and byte to the guest, so drift on either side fails the test.@cipherstash/authpatch.Behaviour changes
vendorfield in error payloads and the message text do not change.Error::Backendfield rename and type change.Error::Unexpected(STATUS_KMS_OTHER), not a backend error that named"none".Verification
Run on the top branch of this stack (
james/kms-vendor-dispatch), on macOS:cargo fmt --all --checkandcargo clippy --workspace --all-features --all-targets -- -D warnings: pass.mise x --env test -- cargo nextest run --workspace --all-features: 1401 of 1402 pass. The one failure isstack-encrypt::ui derive_diagnostics(trybuild). It fails on every snapshot because of a local rustc wrapper that changes the paths in the compiler output. This stack does not touchstack-encrypt. CI is the check for it.mise run wasm:guest:test: 80 of 80 pass.go vet ./...andgo test -count=1 ./...inlanguages/golang: pass.pnpm --filter @cipherstash/auth test: 92 pass.pnpm --filter stash test: 1667 pass.cargo checkof the workspace and the guest (native andwasm32-wasip1) on each branch of the stack: pass.Related
Refs #1541. Code-smell follow-up to the key vendor backend stack.