Skip to content

feat(cli): link errors to troubleshooting articles - #7749

Draft
nrichers wants to merge 2 commits into
developfrom
nikrichers/cli-error-doc-url
Draft

nrichers wants to merge 2 commits into
developfrom
nikrichers/cli-error-doc-url

Conversation

@nrichers

@nrichers nrichers commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Draft for experimentation & demo. Not ready to review or merge.

Summary

What. When an error has a known code with a troubleshooting article on supabase.com/kb, the text output prints a Learn more: <url> line after the error. The JSON and stream-json output add error.docUrl. When no article exists, the output does not change. Existing messages and fields stay the same.

Why. Agents read the CLI JSON errors. With docUrl, an agent can follow the link to the fix instead of guessing.

How.

  • The shared error normalization looks up the code once, so every command gets the link. The normalized error has a new optional docUrl field.
  • The lookup checks the code on the error and on its cause chain.
  • When the error has no code, the lookup reads the message. It matches (SQLSTATE X), a failed SASL or SCRAM exchange (mapped to 28P01), and status 403: (mapped to 403).
  • The text output prints Learn more: <url> last. The JSON and stream-json output put docUrl in the error object.
  • db query previously dropped the driver error code on the raw query path. queryRaw now keeps the SQLSTATE on DbExecError, and the db query error that wraps it carries the same code. Without this fix, a Postgres server error from db query could not reach the lookup.

The vendored slice. apps/cli/src/shared/output/error-links.json is the cli slice of the errors frontmatter in supabase/troubleshooting. That data is to be published at https://supabase.com/kb/error-links.json. It is not live yet. For now the slice is hand-vendored. The script refresh:error-links fetches the published file, so it fails until the file is live. A knip jq ignore covers the script.

Linked issue

  • The linked issue is open and carries the open-for-contribution label (or I'm a Supabase maintainer).

Supabase team member; the work is tracked in Linear.

Known limits

  • The TLS code UNABLE_TO_VERIFY_LEAF_SIGNATURE and the Management API 403 are covered by unit tests only. I could not reproduce them locally.
  • Only the codes in the vendored slice get a link.

Open questions for reviewers

  1. The Learn more wording. I kept it for now. Other wording is under discussion.
  2. The JSON field name docUrl.
  3. Is the vendored-slice approach acceptable, given that the published file is not live yet?

Checklist

  • The PR title follows Conventional Commits (e.g. fix(cli): …).
  • Tests added or updated for the change.
  • From the repository root, pnpm check:all passes; relevant package tests pass for every touched workspace, and pnpm types:check passes for each touched TypeScript workspace (or workspace declaring it).

🤖 Generated with Claude Code

nrichers and others added 2 commits November 18, 2026 08:41
Look up the error code in a vendored slice of supabase.com/kb/error-links.json
in the shared error normalization. Text output prints a "Learn more: <url>"
line after the error and JSON output adds a docUrl field to the error object,
only when the code has an article.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The raw query path dropped the driver error code, so db query failures
could not reach the troubleshooting link lookup. Carry the code on the
execution error and on the db query error that wraps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nrichers nrichers added the do not merge Approve to apply; do not merge. label Nov 22, 2026

This branch has not been deployed

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

Labels

do not merge Approve to apply; do not merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant