Skip to content

[finding] the { success, error: { code, message, details } } envelope published across content/docs/protocol/kernel/error-handling.mdx matches no route's response body #15632

Description

@baozhoutao

Recorded while fixing #15362, which corrected one entry's error CODE on this page. #15362's body explicitly recorded the envelope question as not measured ("the whole section may predate the current envelope; this card records only the code spelling"), so it is filed rather than fixed there.

What the page says

content/docs/protocol/kernel/error-handling.mdx on origin/main 6b8c67778, section ## Standard Error Response (line 55 onward):

{
  "success": false,
  "error": {
    "code": "error_code",
    "message": "Human-readable description",
    "details": { },
    "requestId": "req_abc123",
    "timestamp": "2024-01-16T14:30:00Z"
  }
}

Every per-code example below it repeats that nesting — UNAUTHENTICATED, INVALID_FIELD, RESOURCE_NOT_FOUND, DELETE_RESTRICTED and the rest.

What the routes emit

Flat, with the code at the body's top level and no details object. From packages/rest/src/rest-duplicate-record-arm.test.ts, which asserts the whole body key-for-key:

expect(mapDataError(env, 'duly_note').body).toEqual({
    error: CURATED_NAMED,
    code: 'UNIQUE_VIOLATION',
    developerMessage: env.message,
    field: 'email',
    object: 'duly_note',
});

The same flat shape is what content/docs/protocol/kernel/http-protocol.mdx:757-762 publishes and what ADR-0112's ApiErrorSchema (packages/spec/src/api/contract.zod.ts) describes. The structured context this page puts inside details is carried as top-level siblings instead (field, object, dependentObject, dependentCount, currentVersion, developerMessage), and no arm in structuredCodeAnswer emits success, details, requestId or timestamp at all.

The #15362 PR replaced ONE example with the real body and said so in prose, which leaves the page internally inconsistent until this is graded — deliberately, because rewriting a dozen examples and the envelope section is a different change from correcting a code spelling.

Suggested disposition

Docs-only, but page-wide: decide whether ## Standard Error Response should be rewritten to the ADR-0112 body (and every per-code example with it), or whether the page describes an aspirational envelope that should be removed rather than corrected. Whoever takes it should read packages/rest/src/error-response.ts (structuredCodeAnswer and resolveErrorResponse) for the real terminals, not this page.

Not measured here

Whether requestId / timestamp are emitted anywhere at all, and whether any client or the Console reads the nested shape.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions