mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin UIs call their workers through the bridge routes `bridge/data` and `bridge/action` > - `mapRpcErrorToBridgeError` turns a worker call failure into a bridge error code for the client > - For a plugin with no registered worker, the worker manager rejects with `PluginWorkerUnavailableError` and the message `No worker registered for plugin "<id>"` > - The mapper matched only the substrings `not running` and `not registered`, so this case became `UNKNOWN` > - This pull request makes the mapper recognize the typed error that the worker manager already throws > - The benefit is that clients get `WORKER_UNAVAILABLE` for every "no live worker" case, and the result does not depend on message wording ## Linked Issues or Issue Description Fixes #19092 Refs #19007 (the parent issue that #19092 was split out of) I searched open and closed PRs for `19092`, `mapRpcErrorToBridgeError` and `WORKER_UNAVAILABLE`. I found no related PR. ## What Changed - `mapRpcErrorToBridgeError` in `server/src/routes/plugins.ts` returns `WORKER_UNAVAILABLE` when `findPluginWorkerUnavailableError(err)` finds a `PluginWorkerUnavailableError`, including one wrapped in a `cause` chain. The existing substring checks stay as a fallback. - Added a route test in `server/src/__tests__/plugin-routes-authz.test.ts`. The worker manager mock rejects with the same error and message that `plugin-worker-manager.ts` produces when no worker is registered. The test expects a 502 with `code: "WORKER_UNAVAILABLE"`. ## Verification - `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts --testTimeout=60000`: 38 of 39 tests pass, including the new test. - The one failure is `lists bundled monorepo plugin packages`. It fails the same way on unmodified `master` on my Windows machine, because the postinstall step could not create the plugin SDK symlinks there. It is not related to this change. - Without the fix, the new test receives `code: "UNKNOWN"`. ## Risks - Low risk. Only errors that the worker manager already classifies as worker-unavailable change their bridge code, from `UNKNOWN` to `WORKER_UNAVAILABLE`. The HTTP status stays 502. Nothing is dispatched to a worker in this case, before or after the change. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge