Skip to content

feat(spec): send list-valued query_params as repeated keys - #529

Open
BlueLabelscotch wants to merge 1 commit into
mainfrom
feat/query-params-array
Open

BlueLabelscotch wants to merge 1 commit into
mainfrom
feat/query-params-array

Conversation

@BlueLabelscotch

Copy link
Copy Markdown
Collaborator

Closes #527

A query_params expression that returns a list is now sent as repeated keys instead of being stringified:

query_params:
  kind: '["comment", "change-comment"]'   # ?kind=comment&kind=change-comment
  • New client.Request.QueryParamsMulti; it replaces a QueryParams or path-query value for the same key.
  • Nil, empty and all-blank lists omit the key, as nil does today. Non-list results are unchanged.
  • Applies to paged list endpoints (BuildRequest) and the default branch of callEndpointFull. The file-body, raw-body and get-then-put branches are unchanged.

Compatibility: an expression that already yields a list (e.g. an is_multi flag passed bare) used to be sent as the Go string [a b]; it now becomes repeated keys. Specs that join(...) are unaffected.

@augmentcode augmentcode 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.

Deep Code Review Agent🐛

Review completed with 4 suggestions.

Reviewed commit: b432b03

Comment thread pkg/registry/endpoint.go

// Priority 3: default body_params / body_fn path.
qp := evalQueryParams(ctx, ep.QueryParams, true, extraQueryParams)
qpm := evalQueryParamsMulti(ctx, ep.QueryParams)

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.

Deep Code Review Agent🐛

callEndpointFull passes qpm to the client only when extraHeaders is non-empty; the headerless Get, Post, Put, and Delete helpers receive only the scalar map. A list-valued filter on an ordinary GET or non-paged list therefore goes missing from the URL, and previews of headerless writes also omit the values.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/registry/endpoint.go
params[paramName] = result
}
}
single, _ := endpoint.EvalQueryParams(exprEnv, exprs)

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.

Deep Code Review Agent🐛

evalQueryParams now discards list results, so callers that only use this helper—including file-body requests and both legs of get-then-put—omit keys they previously sent as strings. Those branches are described as unchanged, but supplying --file can now silently remove a query parameter from the same command.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/client/client.go
}
}
for k, vs := range r.QueryParamsMulti {
q.Del(k)

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.

Deep Code Review Agent🐛

Applying QueryParamsMulti last makes a spec list override a scalar that ApplyQueryParamsFn or InjectPaging writes later in request assembly, even though those writes previously took precedence over the spec. This can send the spec's filter instead of the callback's value or keep the page index fixed while the CLI advances it. Other locations where this applies: pkg/endpoint/paging.go:74, pkg/registry/endpoint.go:268

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/endpoint/query.go
if list, isList := asList(out); isList {
var vals []string
for _, item := range list {
if s := exprenv.ResultString(item); s != "" {

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.

Deep Code Review Agent🐛

ResultString treats the literal strings <nil> and map[] as empty, so EvalQueryParams drops those values even when they are explicitly supplied as list items. A multi-value search for either string can therefore lose its filter entirely.

Severity: low


🤖 Was this useful? React with 👍 or 👎

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.

query_params: support array values as repeated keys (kind=a&kind=b)

1 participant