Repository navigation
Description
Describe the bug
WorkBuddy and OpenCode report every HTTP 404 as version_mismatch. The Server returns 404 in two cases:
- A route that does not exist returns an uncoded 404,
{"detail":"Not Found"}. Only this case means that the plugin and the Server versions do not match. - A configured Scope that does not exist returns a coded 404,
{"error":{"code":"scope_not_found",...}}. The Server returns it fromPOST /v1/scope-bindings/resolve, and also from/v1/context/prepare,/v1/sources/content, and/v1/memory/flushwhen the request names an unknownscope_id.
For a coded 404, the version-mismatch advice is wrong. The documented action for version_mismatch is to install the package and plugin from the same ref (for example, troubleshoot.md:402), and that does not help when the Scope itself is missing. The plugin contract also says that version_mismatch "MUST NOT be inferred from a direct resource lookup" (plugin-contract.md:34).
Where the mapping happens (master 0c1dfc28):
- WorkBuddy hook.
workbuddy_powercontext_hook.py:202maps a Scope resolution 404 toversion_mismatch, and:552-553does the same for a prepare 404. The error code is lost before either mapping runs.ScopeBindingStatusError(scripts/workspace_scope.py:65-71, raised at:262) and_HttpStatusError(hook:99-102, raised at:490) keep only the status and never read the error body. - OpenCode statusline.
src/tui.tsx:152-157returnsversion_mismatchfor any 404 and shows "PC version mismatch". This mapping applies to Scope resolution (scopeFailureOutcome) and toget_stats(statsFailureOutcome). The code is already available:ServerResponseError.code(src/errors.ts:55-66) holdserror.codefrom the body, buthttpOutcomereads only the status. In theget_statspath,src/invoke.ts:74gives an uncoded 404 the fallback codenot_found, soToolResult.codealone cannot tell the two cases apart.
The other hosts already classify a 404 by its error code. Pi, OpenClaw, DSH, and Hermes report version_mismatch only for an uncoded 404 from a compatibility or availability path (isVersionMismatch / COMPATIBILITY_OR_AVAILABILITY_PATHS). Kimi Code and ZCode map 404 to not_found, never to version_mismatch. Claude Code and Codex treat a 404 from Scope resolution the same way, and #2317 fixes that.
Steps to reproduce
- Start a Server from master with the default settings (loopback, authentication off).
- Set a Scope ID that does not exist:
POWERCONTEXT_WORKBUDDY_SCOPE_ID=scp_missingfor WorkBuddy, orPOWERCONTEXT_OPENCODE_SCOPE_ID=scp_missingfor OpenCode. - WorkBuddy: submit a prompt. OpenCode: open the TUI and look at the statusline.
To see the two response shapes directly (with authentication on, add the Authorization header to both requests):
curl -s -X POST http://127.0.0.1:8000/v1/scope-bindings/resolve -H 'content-type: application/json' -d '{"explicit_scope_id":"scp_missing"}'
# 404 {"error":{"code":"scope_not_found","message":"The requested Scope was not found.","details":null}}
curl -s -X POST http://127.0.0.1:8000/v1/no-such-route
# 404 {"detail":"Not Found"}Expected behavior
Only a 404 without an error code is reported as version_mismatch. A coded 404 such as scope_not_found is reported as invalid_response and carries its status and code, the same classification that #2317 applies to Claude Code and Codex.
Actual behavior
Observed with both hosts' master code against a master Server:
- WorkBuddy writes
{"component":"powercontext.workbuddy.recall","event":"context_prepare","outcome":"version_mismatch","http_status":404}to stderr. - The OpenCode statusline shows "PC version mismatch".
Proposed fix
Classify a 404 by its error code, as #2317 does. Do not change the Server.
- WorkBuddy. Read
error.codefrom the body of an error response in bothworkspace_scope.pyand_post_json, and keep it onScopeBindingStatusErrorand_HttpStatusError. Map only a 404 without a code toversion_mismatch; any other 404 becomesinvalid_response. Adderror_codeto the diagnostic event when the code is present. A code is not content, so the event stays content-free. - OpenCode. Pass the error code into
httpOutcome, usingServerResponseError.codefor Scope resolution. Forget_stats, carry the Server's code separately from thenot_foundfallback, or checkerror.codebeforeerrorResultrewrites it. - Docs and tests. Update the WorkBuddy failure table in both locales (
workbuddy.md:291). The OpenCode testtests/tui.spec.tsx:265currently expects "PC version mismatch" for a coded 404 ({"error":{"code":"failure"}}), so it has to change. Add a test for a coded 404 and for an uncoded 404 in each host.
In step 4 of #2250, WorkBuddy moves onto the Python lifecycle module and OpenCode onto the TypeScript one. That plan does not allow a move to change behavior, so this fix lands before the move, as #2317 does for Claude Code and Codex.
Environment
- PowerContext version: master
0c1dfc28 - Hosts: WorkBuddy, OpenCode
Related: #2317 (the same fix for Claude Code and Codex), #2250 (lifecycle plan).
Are you willing to submit a PR to fix this bug?
- Yes, I would like to submit a PR.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(integrations): report a coded 404 as an invalid response in WorkB…