Skip to content

fix(api): use query params for --field with GET requests#59

Merged
BYK merged 6 commits intomainfrom
fix/api-get-fields-query-params
Jan 23, 2026
Merged

fix(api): use query params for --field with GET requests#59
BYK merged 6 commits intomainfrom
fix/api-get-fields-query-params

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Jan 23, 2026

Summary

Fixes TypeError: Request with GET/HEAD method cannot have body when using sentry api --field with GET requests.

Changes

  • GET requests: --field values become URL query parameters
  • Other methods (POST/PUT/PATCH/DELETE): --field values become JSON request body (unchanged)
  • Arrays: Use repeated keys per HTTP standard (tags=[1,2,3]?tags=1&tags=2&tags=3)

Files Changed

  • src/commands/api.ts - Added buildQueryParams(), updated command to route fields based on method
  • src/lib/api-client.ts - Updated buildSearchParams() to handle string arrays for repeated keys
  • test/commands/api.test.ts - Added tests for buildQueryParams()

GET/HEAD requests cannot have a body, so --field values were causing
'Request with GET/HEAD method cannot have body' errors.

Now fields are routed based on HTTP method:
- GET: fields become URL query parameters
- POST/PUT/PATCH/DELETE: fields become JSON request body

Arrays use repeated keys per HTTP standard (tags=[1,2,3] → ?tags=1&tags=2&tags=3).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 23, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Issue

  • Add workspace-scoped alias cache by BYK in #52
  • Add short ID aliases for multi-project support by BYK in #31

Other

  • (auth) Add press 'c' to copy URL during login flow by betegon in #58
  • (commands) Rename get commands to view and add -w browser flag by BYK in #53

Bug Fixes 🐛

  • (api) Use query params for --field with GET requests by BYK in #59
  • (issue) Use org-scoped endpoint for latest event + enhanced display by betegon in #40

Documentation 📚

  • Update command references from 'get' to 'view' and document -w flag by BYK in #54

Internal Changes 🔧

  • (release) Fix changelog-preview permissions by BYK in #41
  • Rename config folder from .sentry-cli-next to .sentry by BYK in #50

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 23, 2026

Codecov Results 📊

✅ Patch coverage is 95.56%. Project has 1525 uncovered lines.
✅ Project coverage is 56.64%. Comparing base (base) to head (head).

Files with missing lines (18)
File Patch % Lines
human.ts 9.42% ⚠️ 731 Missing
oauth.ts 21.71% ⚠️ 202 Missing
resolver.ts 3.23% ⚠️ 120 Missing
api-client.ts 51.26% ⚠️ 116 Missing
errors.ts 5.94% ⚠️ 95 Missing
fixture.ts 28.74% ⚠️ 62 Missing
errors.ts 51.61% ⚠️ 60 Missing
api.ts 72.17% ⚠️ 59 Missing
preload.ts 39.02% ⚠️ 25 Missing
detector.ts 87.79% ⚠️ 16 Missing
cache.ts 76.27% ⚠️ 14 Missing
config.ts 97.11% ⚠️ 7 Missing
colors.ts 85.42% ⚠️ 7 Missing
index.ts 95.06% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
alias.ts 96.43% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    55.92%    56.64%    +0.72%
==========================================
  Files           33        33         —
  Lines         3480      3517       +37
  Branches         0         0         —
==========================================
+ Hits          1946      1992       +46
- Misses        1534      1525        -9
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review January 23, 2026 21:59
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@BYK BYK merged commit af5869c into main Jan 23, 2026
15 checks passed
@BYK BYK deleted the fix/api-get-fields-query-params branch January 23, 2026 23:44
MathurAditya724 added a commit that referenced this pull request Apr 6, 2026
The metrics feature was labeled 'Custom Metrics' in the feature selection
prompt, which doesn't match Sentry's standard terminology. Rename to
'Metrics' for consistency.

Closes getsentry/cli-init-api#59
MathurAditya724 added a commit that referenced this pull request Apr 6, 2026
## Summary

- Renames the metrics feature label from "Custom Metrics" to "Metrics"
in the `sentry init` feature selection prompt
- Updates the hint text from "Track custom business metrics" to "Track
business metrics"

The "Custom" qualifier is inaccurate and doesn't match how the feature
is described elsewhere in Sentry's terminology.

Closes getsentry/cli-init-api#59
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