Skip to content

fix: remove false Content-Encoding gzip header causing 500 on child entity creates#150

Closed
shaank0 wants to merge 1 commit intowyre-technology:mainfrom
shaank0:fix/remove-false-gzip-content-encoding
Closed

fix: remove false Content-Encoding gzip header causing 500 on child entity creates#150
shaank0 wants to merge 1 commit intowyre-technology:mainfrom
shaank0:fix/remove-false-gzip-content-encoding

Conversation

@shaank0
Copy link
Contributor

@shaank0 shaank0 commented Mar 13, 2026

Summary

  • Remove false Content-Encoding: gzip header from transformRequest in both AutotaskClient.ts and client-generator.ts. The header claimed gzip encoding but the body was plain JSON.stringify() — never actually compressed. This caused the Autotask API to return 500 Internal Server Error on child entity endpoints (POST /Quotes/{id}/Items, POST /Tickets/{id}/Notes) which strictly validate the encoding. Top-level endpoints were lenient and ignored the mismatch.
  • Improve ServerError messages to include error details from responseData.errors for 500 responses. Previously, 500 errors showed only the generic "Internal Server Error" status text, making debugging extremely difficult.

Root Cause

In AutotaskClient.ts line ~414:

// BEFORE (broken):
transformRequest: [
    (data, headers) => {
        if (defaultPerformanceConfig.enableCompression && data) {
            headers!['Content-Encoding'] = 'gzip';  // Claims gzip...
        }
        return JSON.stringify(data);  // ...but sends plain JSON!
    },
],

// AFTER (fixed):
transformRequest: [
    (data) => {
        return JSON.stringify(data);
    },
],

The same bug existed in client-generator.ts and is fixed there too.

Impact

  • All child entity creates (QuoteItems, TicketNotes, ProjectNotes, CompanyNotes) were broken with 500 errors
  • Top-level creates (Quotes, Opportunities, Companies, Tickets) worked because those endpoints tolerated the header mismatch
  • The decompress axios option for response decompression is unaffected — this only changes request encoding

Test plan

  • npx tsc — compiles without errors
  • Pre-existing test failures confirmed unrelated (same failures before and after this change)
  • Verified fix works against live Autotask API — created 10 QuoteItems successfully after removing the header
  • autotask-mcp should update its autotask-node dependency to this fix

Related

  • wyre-technology/autotask-mcp#32 — workaround that passes enableCompression: false; can be simplified after this fix

🤖 Generated with Claude Code

…ld entity creates

The transformRequest in AutotaskClient and client-generator set
Content-Encoding: gzip on all POST/PUT/PATCH requests but only
JSON.stringify'd the data — never actually compressing it with zlib.

This caused the Autotask API to return 500 Internal Server Error on
child entity endpoints (POST /Quotes/{id}/Items, POST /Tickets/{id}/Notes)
which strictly validate Content-Encoding. Top-level endpoints like
POST /Quotes and POST /Opportunities were lenient and ignored the
mismatch, making the bug intermittent and hard to diagnose.

Fix: Remove the false Content-Encoding: gzip header entirely. Small
JSON API payloads don't benefit from request compression, and the
decompress option on the axios instance still handles response
decompression correctly.

Also improves ServerError messages to include error details from
the Autotask API response body (responseData.errors), which were
previously swallowed — making 500 errors show only the generic
"Internal Server Error" status text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
asachs01 added a commit that referenced this pull request Mar 15, 2026
The Autotask API often returns actionable error details in the `errors`
array even for 500-level responses. Previously these were swallowed and
only the generic status message was shown, making debugging difficult.

Cherry-picked from shaank0/fix/remove-false-gzip-content-encoding (PR #150).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@asachs01
Copy link
Collaborator

Closing in favor of PR #154 which extracts the error message improvement rebased cleanly onto main. The gzip removal is not included since main already properly compresses when enableCompression=true.

@asachs01 asachs01 closed this Mar 15, 2026
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.

2 participants