Repository navigation
docs: add an error model reference - #1270
Merged
Merged
Conversation
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.
|
VarshithaPamisetty
approved these changes
Nov 3, 2026
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.
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AWS Blocks has no single place that explains how errors work end to end. The pieces are spread out:
docs/DECISIONS.mdsays the errornamecrosses the wire.docs/design/API-DESIGN.mdsays how to name error constants.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
docs/reference/error-model.mdmainimplements it todaydocs/README.mdAGENTS.mdThe page covers:
{Block}Errors,isBlocksError,blocksError,brandBlocksError,ApiErrorwithretriable,hasAuthError);ApiError, a brandedErrorand anything else, with an example envelope;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;Symbol.forrather thaninstanceof(duplicate copies of core);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
AuthErrorsconstant. The auth section here names today'sAuthBasicErrors/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 ofAGENTS.md.Validation
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'setAuthStatecatch paths, and D-003 with its amendment.@aws-blocks/core(isApiErrorLikeis internal, and the page says so);AuthBasicErrors,AuthCognitoErrors,AuthOIDCErrorsand theNotAuthorized,ConditionalCheckFailedandInvalidInputconstants used in examples exist.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.