Repository navigation
Keep one list of Harbor's error codes, and make the docs match it - #133
Open
samuelcole wants to merge 7 commits into
Open
samuelcole wants to merge 7 commits into
samuelcole wants to merge 7 commits into
Conversation
The background's ApiErrorCode union and the page API's ErrorCodes were separate hand-kept lists, and both had drifted from what handlers send. ApiErrorCode is now derived from ErrorCodes, ErrorCodes gains the 20 codes the extension emits that it was missing, and a test fails if the source emits an ERR_* code that isn't on the list. No code a page sees changes. Also delete WebAgentError, which nothing used. Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
An invocation Harbor couldn't deliver came back with one of seven one-off codes. They now use the documented codes for what happened: - ERR_AGENT_NOT_ACCEPTING when the target doesn't accept invocations or has no handler (was ERR_NOT_ACCEPTED or ERR_NO_HANDLER). - ERR_AGENT_NOT_FOUND when the agent's page can't be reached (was ERR_NO_TAB or ERR_SEND_FAILED). - ERR_INTERNAL when Harbor's own delivery throws (was ERR_FORWARD_FAILED or ERR_INVOCATION_FAILED). ERR_FAILED sat in a callback nothing called; it's deleted with it. ERR_NOT_INSTALLED, ERR_SCOPE_REQUIRED and ERR_TOOL_TIMEOUT leave the list because nothing sends them. The test harness's mock threw ERR_SCOPE_REQUIRED for a missing scope; it now throws ERR_PERMISSION_DENIED, as Harbor does. The list test now also fails on a listed code nothing sends, and on a doc naming a code Harbor doesn't have. The docs still fail it; the next commit fixes them. Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
# Conflicts: # docs/TESTING_YOUR_APP.md
This branch has not been deployed
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.
Fixes HBR-107
Problem
Harbor kept two hand-maintained lists of error codes: the background's
ApiErrorCodeunion and the page API'sErrorCodes. Both had drifted from what handlers send. Along the way:ERR_NOT_ACCEPTED,ERR_NO_HANDLER,ERR_NO_TAB,ERR_SEND_FAILED,ERR_FORWARD_FAILED,ERR_INVOCATION_FAILED,ERR_FAILED).ERR_USER_GESTURE_REQUIRED,ERR_SCOPE_REQUIRED,ERR_NOT_INSTALLED,ERR_TOOL_TIMEOUT,ERR_RATE_LIMITED, and several MCP and bridge codes. Example code in four docs handledERR_SCOPE_REQUIRED, which can't happen.ERR_SCOPE_REQUIREDfor a missing scope, so apps tested against it checked for a code Harbor never sends.WebAgentErrorhad no callers.Change
One list.
ErrorCodesinextension/src/page-api/types.tsis the only list, andApiErrorCodeis an alias of it. It holds exactly the codes the extension sends.Overlapping invocation codes merged into the documented ones:
ERR_AGENT_NOT_ACCEPTINGwhen the target doesn't accept invocations or has no handler.ERR_AGENT_NOT_FOUNDwhen its page can't be reached. That's what Harbor already sends when the page is gone.ERR_INTERNALwhen Harbor's own delivery throws. Deliberately notERR_HANDLER_FAILED, which marks an answer as the agent's own and gives it provenance.The never-called
rejectcallback that heldERR_FAILEDis deleted.Docs and spec match Harbor. docs/WEB_AGENTS_API.md now has the one complete table. The other docs keep short tables of the codes their surface returns, plus a link to it.
spec/explainer.mdand its mirrordocs/HARBOR_WEB_API_EXPLAINER.mdnow list exactly Harbor's codes. The spec no longer promises a user-gesture check, andspec/security-privacy.mdno longer shows a rate-limit step. Neither is enforced. TheERR_LABEL_FLOW_BLOCKEDrow was marked "reserved, not produced", but the policy engine does produce it, so the row now says what it means.Harness mock throws
ERR_PERMISSION_DENIEDfor a missing scope, as Harbor does when the person declines.A test keeps it all in step.
extension/src/page-api/__tests__/error-codes-list.test.tsfails in any of these cases:Also fixed
ARCHITECTURE.mdsaid the codes live inshared/protocol.ts, which doesn't exist.Testing
npm test --prefix extension: 159 files, 1794 tests pass.npm run build(Firefox) passes.npx tsc --noEmit -p extension: 36 errors at base (aef1ea5) and at head, with identical lists.ERR_INTERNALcatch inagents/handlers/multi-agent.ts. Only the list test reaches it. Also,docs/MCP_HOST.md's "server down returnsERR_TOOL_FAILED" matches the code, but no test exercises that case.What's left
ERR_CHAT,ERR_CHAT_OPEN,ERR_CHAT_CLOSEand the threeERR_MCP_*codes stay as they are. They're documented and tested, and pages may rely on them.Opened by Claude Code.
🤖 Generated with Claude Code