Skip to content

Bug: useCreateTag/useUpdateTag/useSetMonitorTags crash on non-JSON error responses #310

@bd73-com

Description

@bd73-com

Bug: Tag mutation hooks crash on non-JSON error responses

Severity: low
Location: client/src/hooks/use-tags.ts:32, :63, :122

Background

Three mutation hooks in use-tags.ts handle HTTP error responses by calling await res.json() without a .catch() fallback. Other hooks in the codebase (e.g., use-conditions.ts:45, use-notification-channels.ts:46) consistently use await res.json().catch(() => ({})) to gracefully handle non-JSON error bodies.

How to Reproduce

  1. Navigate to tag management
  2. Trigger a condition where the server returns a non-JSON error (e.g., reverse proxy 502/503 HTML page, WAF interception)
  3. Attempt to create, update, or assign a tag

Actual Result

Toast displays a SyntaxError like "Unexpected token '<', '<!DOCTYPE '... is not valid JSON" instead of a helpful error message. The real HTTP status and error context are lost.

Expected Result

The hooks should gracefully handle non-JSON error responses by adding .catch(() => ({})) to the res.json() calls on lines 32, 63, and 122, matching the pattern used by useDeleteTag (line 92) in the same file.

Affected hooks

  • useCreateTag() — line 32
  • useUpdateTag() — line 63
  • useSetMonitorTags() — line 122

Found by

Magicwand Phase 6 (Bug Reporter independent scan) on branch claude/test-custom-hooks-ZfYH2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglowLow severity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions