Skip to content

fix: prevent delete failures on empty successful API responses#22

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/critical-bug-inspection-1bf3
Draft

fix: prevent delete failures on empty successful API responses#22
cursor[bot] wants to merge 1 commit intomainfrom
cursor/critical-bug-inspection-1bf3

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Mar 28, 2026

Summary

  • Fixes a critical correctness bug in PixelmuseClient.request where all successful responses were forced through res.json().
  • Handles successful empty responses (204/205) by returning undefined instead of throwing a JSON parse error.
  • Adds focused client tests covering:
    • deleteGeneration on 204 No Content
    • normal JSON success parsing on getGeneration
    • structured JSON error parsing into ApiError

Bug / Impact

Deleting a generation could fail even when the server successfully deleted it (common REST behavior is 204 No Content).

Root Cause

request<T> always executed return (await res.json()) as T for all 2xx responses. For empty-body success responses, JSON parsing throws (Unexpected end of JSON input), bubbling up as an error and breaking critical delete flows.

Validation

  • Installed dependencies with pnpm install
  • Ran:
    • pnpm build
    • pnpm test
  • Result: all tests pass (including new regression tests).
Open in Web View Automation 

Co-authored-by: Dylan Boudro <starmorph@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant