Skip to content

Engine errors have codes but no documentation links — decide the URL format and give every code a page #1790

Backlog

Description

@coderdan

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.

  1. No engine error links to a page. The five crates define 164 codes (stack_encrypt 97, stack_kms 30, stack_auth 25, stack_profile 8, stack_guest_abi 4). Only two have a URL, and neither is a page about the error: stack_auth::usage_limit_exceeded links to the billing dashboard and stack_auth::org_not_provisioned links to support (packages/stack-auth/src/error.rs:366 and :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.
  2. The SDKs already have the field, and it is always empty. The Go SDK's Diagnostic has a URL field (languages/golang/internal/guest/diagnostic.go), and the TypeScript SDK's RecipherError has a url property. Both read miette's url(). A user who prints an error gets the code and the help, and no link.
  3. 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.
  4. Some codes are outside the engine's namespace. The TypeScript SDK gives 39 errors a code of its own (recipher::not_a_ciphertext and 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.
  5. 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.
  6. 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.rs and again for TypeScript in languages/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

  1. 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/aead for stack_encrypt::aead. This is a decision for the engine and docs owners.
  2. Build the URL in one place. Add a function to stack-profile's diagnostic module that returns an error's own url() when it has one, and otherwise the page address built from its code. This avoids writing 164 url(...) attributes that can each be mistyped, and keeps the two stack-auth links that point somewhere else on purpose. The Go guest's encoder and the TypeScript addon both call it.
  3. Move the cause walk to the same module, so Go and TypeScript share one copy of the rule in item 6.
  4. Decide what the SDK codes and the vitaminc codes link to. Proposed: recipher::… and stack_guest_abi::… get pages under the same scheme. The vitaminc ERR_… codes either get pages in the same place or the TypeScript SDK gives them recipher::… names.
  5. 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.rs and 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

Activity

  1. added
    enhancement
    Rust
    on Nov 24, 2026
  2. coderdan commented on Nov 24, 2026

    @coderdan
    ContributorAuthor

    A note on where the shared code in items 2 and 3 should live.

    The proposal says to add it to stack-profile's diagnostic module. That is where the ErrorPayload trait 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-auth from stack-profile, stack-kms from stack-auth, and stack-encrypt from stack-kms.

    It is an odd home. stack-profile stores the credentials and client key for local development, and the diagnostic module has nothing to do with that. It appears to be there only because stack-profile is 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-profile would 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RustSDKenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions