fix(tasks-api): guard against HTML catch-all responses - #408
Closed
goforgin wants to merge 1 commit into
Closed
Conversation
The /api/hermes-tasks route was renamed to /api/claude-tasks in commit efcb7d1, but the probe logic still listed the old route as a candidate. When probed, the SPA catch-all returned a 200 HTML response instead of a 404, so probeBackend() treated it as a valid (empty) backend and then failed when the actual task fetch threw. Fixes: - probeBackend() now checks Content-Type: application/json and returns -1 for non-JSON responses, so future route renames degrade gracefully. - resolveBackend() now only selects hermes if hermesCount > 0, defaulting to claude-tasks (the active backend post rename) when hermes is absent.
Owner
|
Closing as superseded by #432. The validated fix was folded into the consolidated batch branch |
Closed
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.
Problem
After commit
efcb7d14renamed/api/hermes-tasks→/api/claude-tasks, the task board showed "Failed to load tasks" in all columns despite the backend being healthy.Root cause
probeBackend()intasks-api.tsstill probed the old/api/hermes-tasksroute. Since the SPA catch-all returns200 OKwith an HTML body (not a 404),probeBackend()saw a successful response and didn't treat it as a dead route. ThenresolveBackend()selectedhermes-tasksas the winner (both counts were 0, and the old logic defaulted to hermes when equal), and the actual task fetch to that dead route threw — causing the board to fail entirely.Fix
Two changes to
src/lib/tasks-api.ts:probeBackend()— checkContent-Type: application/jsonafter a 200 response. Return-1for non-JSON (HTML catch-all) instead of treating it as a valid empty backend.resolveBackend()— only preferhermes-taskswhenhermesCount > 0. When hermes is absent or returns non-JSON, default toclaude-tasks(the active backend post-rename).How to reproduce (before fix)
/api/claude-tasks(post-rename)After fix
Tasks board loads correctly via
/api/claude-tasks. If/api/hermes-tasksis ever restored and has data, it will still be preferred automatically.