Skip to content

Fix Go SDK Content-Type on GET requests#334

Open
robzolkos wants to merge 5 commits into
basecamp:mainfrom
robzolkos:fix-go-get-content-type
Open

Fix Go SDK Content-Type on GET requests#334
robzolkos wants to merge 5 commits into
basecamp:mainfrom
robzolkos:fix-go-get-content-type

Conversation

@robzolkos

@robzolkos robzolkos commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • stop setting Content-Type: application/json on bodyless Go SDK requests
  • keep Accept: application/json on requests and keep Content-Type for JSON bodies
  • add regression coverage for raw GETs and generated Search GETs

Why

Content-Type describes the request body. Bodyless GET requests use URL query parameters, and sending Content-Type: application/json causes /search.json?q=... to return unfiltered results.

Fixes #324.

Tests

  • go test ./go/pkg/basecamp
  • go test ./go/...

Summary by cubic

Stop sending Content-Type: application/json on bodyless GET requests in the Go SDK (go/pkg/basecamp) to fix unfiltered /search.json results (Fixes #324). Accept: application/json stays; Content-Type is only set when a JSON body exists and isn’t already set.

  • Bug Fixes
    • Add requestHasBody and use it in the generated client and singleRequest so Content-Type is only set with a body; always set Accept: application/json.
    • Tests cover: GET without Content-Type, POST sets JSON Content-Type, POST preserves an existing Content-Type via an auth strategy and asserts it was empty before auth runs, and Search GET checks headers and q param.

Written for commit 767a8ff. Summary will update on new commits.

Review in cubic

Copilot AI review requested due to automatic review settings June 10, 2026 14:36
@github-actions github-actions Bot added go bug Something isn't working labels Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds safeguards to avoid sending a Content-Type header on bodyless GET requests, aligning request headers with HTTP semantics and preventing confusing/incorrect metadata.

Changes:

  • Update client request building to only set Content-Type: application/json when a body is present.
  • Introduce a requestHasBody helper used by the generated-client request path.
  • Add tests covering GET (no Content-Type) and POST (JSON Content-Type) behavior, plus a higher-level search test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
go/pkg/basecamp/search_test.go Adds a regression test ensuring Search() GET requests don’t send Content-Type.
go/pkg/basecamp/client_test.go Adds unit tests asserting correct header behavior for GET vs POST.
go/pkg/basecamp/client.go Changes header-setting logic to be body-aware; adds requestHasBody helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go/pkg/basecamp/search_test.go
Comment thread go/pkg/basecamp/search_test.go Outdated
Comment thread go/pkg/basecamp/client_test.go
Comment thread go/pkg/basecamp/client.go Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread go/pkg/basecamp/client_test.go
@robzolkos

Copy link
Copy Markdown
Collaborator Author

Fixed — addressed the review feedback by adding method assertions, using http.StatusOK, and aligning body detection.

@robzolkos

Copy link
Copy Markdown
Collaborator Author

Fixed — added the GET method assertion identified by cubic.

Copilot AI review requested due to automatic review settings June 10, 2026 14:59
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file ruby Pull requests that update the Ruby SDK labels Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

Comment thread go/pkg/basecamp/client.go Outdated
Comment thread go/pkg/basecamp/client_test.go
Comment thread go/pkg/basecamp/search_test.go
@robzolkos

Copy link
Copy Markdown
Collaborator Author

Fixed — addressed the latest Copilot review feedback by preserving existing Content-Type values and avoiding t.Fatalf in httptest handler goroutines.

Copilot AI review requested due to automatic review settings June 10, 2026 16:42
@github-actions github-actions Bot removed dependencies Pull requests that update a dependency file ruby Pull requests that update the Ruby SDK labels Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread go/pkg/basecamp/search_test.go Outdated
Comment thread go/pkg/basecamp/client.go Outdated
@robzolkos robzolkos force-pushed the fix-go-get-content-type branch from c0b8fe1 to 0d03f1d Compare June 10, 2026 18:30
Copilot AI review requested due to automatic review settings June 10, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread go/pkg/basecamp/client_test.go
Comment thread go/pkg/basecamp/client_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search doesn't filter the results

2 participants