Repository navigation
Description
Background
The Stack Encrypt engine is the Rust code that encrypts and decrypts values. It is five crates: stack-encrypt, stack-kms (the client for ZeroKMS, CipherStash's key-management service), stack-auth, stack-profile and stack-guest-abi. The language SDKs (Go today, TypeScript in progress) are built on it.
Every error in those crates is a miette diagnostic. miette is a Rust error library that lets an error carry a stable code (such as stack_encrypt::aead), a help text that says what to do, and a URL for a documentation page. #1099 gave every error a code and help. The aim is one documentation page for each code, so a person or an agent who hits an error can go straight to its explanation.
Problem
The errors have codes but no documentation links.
- No engine error links to a page. The five crates define 164 codes (
stack_encrypt97,stack_kms30,stack_auth25,stack_profile8,stack_guest_abi4). Only two have a URL, and neither is a page about the error:stack_auth::usage_limit_exceededlinks to the billing dashboard andstack_auth::org_not_provisionedlinks to support (packages/stack-auth/src/error.rs:366and:388). stack-encrypt, stack-kms and stack-profile errors have no codes or help — add miette path-style codes (stack_encrypt::aead), structured fields, and a rule for what an error may contain #1099 left the URL unset on purpose: "The docs site plans one page per code at a fixed URL, and links should only be added once those pages exist." Nothing tracks that follow-up. - The SDKs already have the field, and it is always empty. The Go SDK's
Diagnostichas aURLfield (languages/golang/internal/guest/diagnostic.go), and the TypeScript SDK'sRecipherErrorhas aurlproperty. Both read miette'surl(). A user who prints an error gets the code and the help, and no link. - The URL format is not decided. Until it is, nobody can add a link, and the docs site cannot build the pages at addresses the code will point to.
- Some codes are outside the engine's namespace. The TypeScript SDK gives 39 errors a code of its own (
recipher::not_a_ciphertextand others). It also passes on six codes from vitaminc, the library that converts values, and those are written differently (ERR_INTEGER_RANGE). The Go guests have four (stack_guest_abi::…). A page-per-code scheme has to cover these too. - The docs site has no list to build from. The docs live in another repository. Today the only way to learn the set of codes is to read the Rust source.
- Two SDKs walk the cause chain with two copies of the same code. The rule for an error's causes (give the code and message of one of our own errors, and never copy the message of another library's error) is written once for Go in
packages/stack-guest-abi/src/last_error.rsand again for TypeScript inlanguages/typescript/packages/recipher-js/crate/src/error.rs. A change to the rule has to be made twice.
Nothing fails because of this today. The cost is that the error work in #1099 stops one step short of what it was for.
Proposal
- Decide the URL format. Proposed: one page per code, with the address built from the code, for example
https://cipherstash.com/docs/errors/stack_encrypt/aeadforstack_encrypt::aead. This is a decision for the engine and docs owners. - Build the URL in one place. Add a function to
stack-profile'sdiagnosticmodule that returns an error's ownurl()when it has one, and otherwise the page address built from its code. This avoids writing 164url(...)attributes that can each be mistyped, and keeps the twostack-authlinks that point somewhere else on purpose. The Go guest's encoder and the TypeScript addon both call it. - Move the cause walk to the same module, so Go and TypeScript share one copy of the rule in item 6.
- Decide what the SDK codes and the vitaminc codes link to. Proposed:
recipher::…andstack_guest_abi::…get pages under the same scheme. The vitamincERR_…codes either get pages in the same place or the TypeScript SDK gives themrecipher::…names. - Write the list of codes to a file the docs site can read. A test already builds one error of every variant in each crate (
packages/stack-encrypt/src/codes.rsand its siblings). Extend it to write, or check, a committed JSON file of every code with its message and help. The docs repository builds a page for each entry and fails its own build when a code has no page.
A cheap first step is item 5 alone: it gives the docs site the list, and it does not depend on the URL decision.
Turn the links on (item 2) only when the pages exist, as #1099 said. A link to a missing page is worse than no link.
Done when
- An error printed from Rust, Go or TypeScript shows a link, and the link opens a page about that error.
- A new error code with no page fails a build somewhere before it is released.
Relationship to other work
- stack-encrypt, stack-kms and stack-profile errors have no codes or help — add miette path-style codes (stack_encrypt::aead), structured fields, and a rule for what an error may contain #1099 (closed) added the codes and help, and deferred the URL.
- Go errors carry only a status number: give stack-encrypt, stack-kms and stack-auth errors codes, help and fields, and carry them into Go (umbrella) #1098 (closed) carried the diagnostic into Go.
- docs(plans): the TypeScript SDK on Stack Encrypt, a core with EQL as an extension #1747 is the TypeScript SDK plan. Its error type now carries
help,url,fieldsandcauses, so it shows the link as soon as the engine has one.
Activity
coderdan commentedon Nov 24, 2026
A note on where the shared code in items 2 and 3 should live.
The proposal says to add it to
stack-profile'sdiagnosticmodule. That is where theErrorPayloadtrait and the rule for what an error may contain live today (packages/stack-profile/src/diagnostic.rs), and the other crates re-export it upward:stack-authfromstack-profile,stack-kmsfromstack-auth, andstack-encryptfromstack-kms.It is an odd home.
stack-profilestores the credentials and client key for local development, and the diagnostic module has nothing to do with that. It appears to be there only becausestack-profileis the lowest crate in the dependency chain, so every other crate can see it.A small crate of its own at the bottom of the chain is probably the better shape. It would hold the trait, the rule, the cause walk and the URL builder, and
stack-profilewould depend on it like the other crates. The cost is one more published crate and moving a public module. The existing re-exports would hide the move from users of the other four crates.This does not need deciding now. Whoever picks up items 2 and 3 should decide it then, before adding more to
stack-profile.