Skip to content

fix(api): send a query string in a GET endpoint with the fields - #189

Open
Eotel wants to merge 1 commit into
nulab:mainfrom
Eotel:Eotel/api-endpoint-query
Open

Eotel wants to merge 1 commit into
nulab:mainfrom
Eotel:Eotel/api-endpoint-query

Conversation

@Eotel

@Eotel Eotel commented Nov 4, 2026

Copy link
Copy Markdown

Summary

bee api sent a GET endpoint's query string and the -f fields as two query strings, because backlog-js appends ? and the params to the path without checking for an existing ?. The API then read the -f fields as part of the last value from the endpoint.

 bee api 'users/myself/recentlyViewedIssues?count=2' -f order=desc
-  GET …/recentlyViewedIssues?count=2?order=desc   # error.number : count
+  GET …/recentlyViewedIssues?count=2&order=desc

This takes option 1 from #188:

  • For GET, the query string is split off the endpoint and sent as params together with -f / -F, as gh api does. The pairs are sent as literal strings, like -F. [] keys and repeated keys become arrays the same way as with -f.
  • POST/PUT/PATCH/DELETE send the fields in the body and leave the URL alone, so their endpoint is kept as given.
  • The --help description now says that a query string in a GET endpoint is sent with the fields.

Evidence

Read-only GET runs of the built CLI against a live space, with API key authentication:

Command Before (main at 707ab80) After
bee api 'users/myself/recentlyViewedIssues?count=2' -f order=desc error.number : count, exit 1 2 items, exit 0
bee api 'notifications/count?alreadyRead=false' -f resourceAlreadyRead=false Cannot parse parameter alreadyRead as Boolean, exit 1 exit 0, same count as passing both with -f
bee api 'users/myself/recentlyViewedIssues?count=2&order=desc' 2 items 2 items
bee api 'users/myself/recentlyViewedIssues?count=3' -f order=asc (and desc) — the same issue IDs, in the same order, as -f count=3 -f order=asc (and desc)

The new GET test failed before the fix and passes after it. The POST test passes before and after; it keeps the split limited to GET.

Not verified:

  • POST with a query string in the endpoint was not run against the live API, because it writes data. Its code path is unchanged.
  • Endpoint values are decoded as form data, so + is sent as a space (%20). Most servers read a raw query string the same way, but I did not compare this case against the live API.

Test plan

  • vp check
  • vp test
  • vp run --filter @nulab/bee build
  • vp run --filter @nulab/bee generate:skill:check
  • Read-only runs of the built CLI against a live space (table above)

Merge Danger

Door: Two-way

The change can be reverted without a data migration.

Blast Radius: bee api GET

A GET endpoint with a query string and no -f already worked on main. It now sends the same parameters as params instead of as part of the path.

Fixes #188

backlog-js appends `?` and the encoded params to the path without
checking for an existing `?`. `bee api 'issues?count=2' -f order=desc`
was sent as `issues?count=2?order=desc`, and the API read the count as
`2?order=desc` and rejected it with "error.number : count".

For GET, the query string is now split off the endpoint and sent as
params together with `-f` / `-F`, as `gh api` does. The pairs are sent
as literal strings, like `-F`. Other methods send the fields in the body
and leave the URL alone, so their endpoint is kept as given.

Fixes nulab#188
@Eotel
Eotel requested a review from lollipop-onl as a code owner November 4, 2026 07:42

This branch has not been deployed

No deployments
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.

bug(api): a query string in the endpoint argument breaks the request

1 participant