Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

[AGENT-793] Fix unnecessary Content-Type header on GET requests - #185

Merged
jhaynie merged 4 commits into
mainfrom
AGENT-793
Oct 1, 2025
Merged

jhaynie merged 4 commits into
mainfrom
AGENT-793

Conversation

@pec1985

@pec1985 pec1985 commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Only send Content-Type: application/json when request body is present. Prevents HTTP servers from rejecting GET requests with unnecessary headers.

Amp-Thread-ID: https://ampcode.com/threads/T-81e76828-0341-4b71-9974-0b7486dd13df

Summary by CodeRabbit

  • Bug Fixes
    • Requests without a body no longer include a Content-Type header, improving compatibility with servers that reject or mishandled that header.
    • Stream closure is now best-effort when the underlying writer is locked, reducing risk of errors during shutdown or cleanup.

Only send Content-Type: application/json when request body is present.
Prevents HTTP servers from rejecting GET requests with unnecessary headers.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-81e76828-0341-4b71-9974-0b7486dd13df
@coderabbitai

coderabbitai Bot commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@jhaynie has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2f29031 and d3efd17.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .changeset/hip-actors-worry.md (0 hunks)
  • CHANGELOG.md (1 hunks)
  • package.json (1 hunks)

Walkthrough

Removed the default Content-Type header from internal request sending so callers must provide Content-Type when needed; also removed a special-case writer-close on TypeError('locked') in StreamImpl.close. Tests and changelog adjusted accordingly.

Changes

Cohort / File(s) Summary
API request header handling
src/apis/api.ts
Removed implicit/default Content-Type from internal send implementation; headers are built without injecting Content-Type (callers must supply it via request.headers). Other request construction, URL resolution, and error paths unchanged.
Stream close behavior
src/apis/stream.ts
Removed special-case handling that attempted to close an active writer when a TypeError with message 'locked' occurred; close now performs best-effort closure without that branch.
Tests
test/apis/api.test.ts
Removed assertions expecting Content-Type: application/json; tests now validate remaining headers (Authorization, User-Agent) only.
Release / changeset
.changeset/tame-meals-occur.md
Bumped patch release and documented removal of implicit Content-Type from internal send path so callers handle it per-request.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant API as API.send
  participant Fetch as fetch()

  Caller->>API: send(url, method, headers?, body?)
  Note over API: Build headers without a default Content-Type\n(do not insert Content-Type based on body)
  alt caller provided Content-Type
    API->>API: Use provided Content-Type in headers
  else no Content-Type provided
    API->>API: Send headers as-is (no Content-Type)
  end
  API->>Fetch: fetch(url, { method, headers, body? })
  Fetch-->>API: Response/Promise
  API-->>Caller: Result
Loading
sequenceDiagram
  autonumber
  participant User
  participant Stream as StreamImpl

  User->>Stream: close()
  Stream->>Stream: attempt close (best-effort)
  alt previous behavior: TypeError('locked') occurred
    Note over Stream: previously tried to close active writer and clear reference\nnow that special-case is removed
  end
  Stream-->>User: resolved/returned (no writer-force-close on locked error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nibble headers in the night,
No bulky types unless you write.
If locks arise, I'll nap instead—
Soft closes, quiet bed. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning In addition to the Content-Type header adjustment, the pull request includes an unrelated modification in src/apis/stream.ts that removes special-case handling for locked writers in StreamImpl.close, which does not pertain to fixing the GET request header issue described in AGENT-793. This stream change falls outside the scope of the linked issue and should be addressed separately. Separate the StreamImpl.close error-handling changes into a distinct pull request or revert them here so that this PR remains focused on the Content-Type header fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “[AGENT-793] Fix unnecessary Content-Type header on GET requests” succinctly and accurately describes the primary change in this pull request, focusing on removing the default Content-Type header for GET requests to address the linked issue. It is concise, specific, and directly related to the core modification without extraneous details or ambiguous language.
Linked Issues Check ✅ Passed The pull request removes the default Content-Type: application/json header in the internal send function, ensuring that GET requests no longer include an unnecessary header and thereby resolving the server rejection error reported in AGENT-793 for vector.get. The accompanying test updates confirm that only requests with bodies will include Content-Type headers, directly addressing the vector.get malfunction described in the linked issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41e0e12 and 9630049.

📒 Files selected for processing (1)
  • src/apis/api.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/apis/**

📄 CodeRabbit inference engine (AGENT.md)

Place core API implementations under src/apis/ (email, discord, keyvalue, vector, objectstore)

Files:

  • src/apis/api.ts
{src,test}/**/!(*.d).ts

📄 CodeRabbit inference engine (AGENT.md)

{src,test}/**/!(*.d).ts: Use strict TypeScript and prefer unknown over any
Use ESM import/export syntax; avoid CommonJS require/module.exports
Use relative imports for internal modules
Keep imports organized (sorted, no unused imports)
Use tabs with a visual width of 2 spaces
Limit lines to a maximum of 80 characters
Use single quotes for strings
Use proper Error types; do not throw strings
Prefer template literals over string concatenation

Files:

  • src/apis/api.ts

Comment thread src/apis/api.ts Outdated
@jhaynie
jhaynie merged commit ea9b7e2 into main Oct 1, 2025
2 checks passed
@jhaynie
jhaynie deleted the AGENT-793 branch October 1, 2025 17:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/tame-meals-occur.md (1)

5-6: Fix incomplete sentence and clarify scope (GET/HEAD, body presence).

Current text trails off and doesn’t state when Content-Type should be set. Suggest explicit, user-facing wording.

-Remove the explicit Content-Type header for application/json in send (internal) to allow each service caller to properly set
+Only set a Content-Type header when a request body is present. Remove the default `Content-Type: application/json` from the internal `send` path so each service sets the header explicitly for requests with bodies. This prevents sending Content-Type on GET/HEAD and avoids unnecessary CORS preflights and server rejections.
+
+Refs: AGENT-793 (vector.get not working), Amp-Thread-ID T-81e76828-0341-4b71-9974-0b7486dd13df.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9630049 and 2f29031.

📒 Files selected for processing (4)
  • .changeset/tame-meals-occur.md (1 hunks)
  • src/apis/api.ts (1 hunks)
  • src/apis/stream.ts (0 hunks)
  • test/apis/api.test.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • src/apis/stream.ts
  • test/apis/api.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/apis/api.ts
🔇 Additional comments (1)
.changeset/tame-meals-occur.md (1)

1-3: Verify default Content-Type in internal requests
Several body-bearing calls in your SDK implementation (e.g. under src/apis, src/io, src/server, src/otel) don’t set an explicit Content-Type header. Confirm your HTTP client wrapper still defaults to application/json for request bodies; if it doesn’t, add the header or bump this change to a minor release.

devin-ai-integration Bot added a commit that referenced this pull request Oct 1, 2025
- Reformat v0.0.147 entry to use Keep a Changelog format with Added and Fixed sections
- Add version comparison links at the bottom of the changelog
- Document PR #186: Stream compression features
- Document PR #185: Fix unnecessary Content-Type header on GET requests

Co-Authored-By: unknown <>
devin-ai-integration Bot added a commit that referenced this pull request Oct 2, 2025
- Add PR link to v0.0.148 entry (#184)
- Add PR links to v0.0.147 entry (#186, #185)
- Add version comparison links at bottom following Keep a Changelog format

Co-Authored-By: unknown <>
jhaynie added a commit that referenced this pull request Oct 4, 2025
* Update changelog for sdk-js v0.0.147

- Reformat v0.0.147 entry to use Keep a Changelog format with Added and Fixed sections
- Add version comparison links at the bottom of the changelog
- Document PR #186: Stream compression features
- Document PR #185: Fix unnecessary Content-Type header on GET requests

Co-Authored-By: unknown <>

* update

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Jeff Haynie <jhaynie@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants