Skip to content

docs: add an error model reference - #1270

Merged
sharonyajain merged 2 commits into
mainfrom
docs/error-model-reference
Nov 3, 2026
Merged

sharonyajain merged 2 commits into
mainfrom
docs/error-model-reference

Conversation

@sharonyajain

Copy link
Copy Markdown
Contributor

Problem

AWS Blocks has no single place that explains how errors work end to end. The pieces are spread out:

  • D-003 in docs/DECISIONS.md says the error name crosses the wire.
  • G6 in docs/design/API-DESIGN.md says how to name error constants.
  • AGENTS.md rule 6 has one line on branding.

Nothing tells a Building Block author or an app author which helper to throw with, why an error has to be branded, what the client gets back for each kind of error, or how the auth blocks report failures without throwing. The old tech-design error-model doc that used to cover this still lives in the staging repo under the KIT names (isKitError, KitError) and predates the brand and the D-003 amendment.

Issue #, if available: n/a, found while auditing the tech-design docs against the code.

Changes

File Change
docs/reference/error-model.md New reference page describing the error path as main implements it today
docs/README.md Lists it under Reference
AGENTS.md Adds it to the "Implementing a New Building Block" checklist

The page covers:

  • the helpers ({Block}Errors, isBlocksError, blocksError, brandBlocksError, ApiError with retriable, hasAuthError);
  • when to brand, and why a branded message must never contain raw driver or SDK text;
  • what the serializer sends for an ApiError, a branded Error and anything else, with an example envelope;
  • the parts that surprise people: RPC errors return HTTP 200 with the status in error.code, a branded plain error always goes out as 500, a handler timeout returns 504, and only cookie deletions survive on an error response;
  • why the brand is a Symbol.for rather than instanceof (duplicate copies of core);
  • how RawRoute and the auth state machine differ.

Docs only. No code or package content changes, so no changeset.

Overlap with #1259: that PR replaces AuthBasic, AuthCognito and AuthOIDC with one Auth block and a single AuthErrors constant. The auth section here names today's AuthBasicErrors / AuthCognitoErrors / AuthOIDCErrors. If #1259 lands first I'll update that section here; if this lands first, it's a two-line change there. The two PRs edit different lines of AGENTS.md.

Validation

  • Written from the code on main: packages/core/src/errors.ts, packages/core/src/rpc.ts, packages/core/src/lambda-handler.ts, packages/core/src/scripts/dev-server.ts, the auth blocks' setAuthState catch paths, and D-003 with its amendment.
  • Checked each claim against the code:
    • every function and constant named on the page exists;
    • every one presented as part of the public API is exported from @aws-blocks/core (isApiErrorLike is internal, and the page says so);
    • AuthBasicErrors, AuthCognitoErrors, AuthOIDCErrors and the NotAuthorized, ConditionalCheckFailed and InvalidInput constants used in examples exist.
  • All relative links resolve.
  • Biome ignores these files under the repo's config; no tests apply to docs.

Checklist

  • PR description included
  • Tests are changed or added (docs only)
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

AWS Blocks covered errors only in pieces: D-003 says the error name
crosses the wire, G6 says how to name error constants, and AGENTS.md
rule 6 has one line on branding. Nothing described the whole path a
Building Block or app author needs: which helper to throw with, why an
error must be branded, what the serializer sends for each kind of
error, what the client gets back, and how the auth state machine
reports failures without throwing.

docs/reference/error-model.md describes that path as the code on main
does it today. Link it from docs/README.md and from the AGENTS.md
checklist for implementing a new Building Block.
Only isWireSafeError is exported from @aws-blocks/core; isApiErrorLike is used by the serializer but not part of the public surface.
@sharonyajain
sharonyajain requested a review from a team as a code owner November 3, 2026 10:05
@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5f7602c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sharonyajain
sharonyajain merged commit 5ba769f into main Nov 3, 2026
41 checks passed
@sharonyajain
sharonyajain deleted the docs/error-model-reference branch November 3, 2026 12:40
harsh62 added a commit that referenced this pull request Nov 3, 2026
Conflict resolution:

- packages/create-blocks-app/templates/auth/src/index.ts: #1239 edited
  templates/auth-cognito/src/index.ts, which this branch renamed to
  templates/auth and rewrote for the unified Auth block. Git applied the
  hunks to the renamed file; the one conflict was in refreshTodos()'s
  catch. Kept this branch's isBlocksError(error,
  'NotAuthenticatedException') check and showError(el, unknown) call, and
  added #1239's boolean returns. #1239's mutateTodo() helper and the
  caught "Show last code" lookup are ported as-is, except that they use
  isBlocksError for the signed-out check and pass the error straight to
  this branch's showError, which already takes unknown, so #1239's
  errorMessage() helper is not needed. No templates/auth-cognito/
  directory is re-created.
- .changeset/auth-cognito-todo-errors.md renamed to
  auth-template-todo-errors.md, and its text now names the `auth`
  template. Package unchanged (@aws-blocks/create-blocks-app, patch).
harsh62 added a commit that referenced this pull request Nov 3, 2026
- docs/reference/error-model.md (#1270): the auth state machine section
  named AuthCognito and the per-block AuthBasicErrors /
  AuthCognitoErrors / AuthOIDCErrors constants. It now names Auth and
  AuthErrors (exported from @aws-blocks/bb-auth, re-exported by
  @aws-blocks/blocks) and links the Auth README.
- docs/native-clients/schema-generation-guide-for-devs.md (touched by
  #1125): the transferable tag table listed bb-auth-oidc as the source
  of oidc/client, and the type-args section described AuthOIDC's
  getClient() in the present tense. The table now says no block
  returns the tag (it stays built in), and the AuthOIDC sentence is
  past tense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants