-
Notifications
You must be signed in to change notification settings - Fork 881
chore: support multiple key:value search query params #12690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if err != nil { | ||
p.Errors = append(p.Errors, codersdk.ValidationError{ | ||
Field: queryParam, | ||
Detail: fmt.Sprintf("Query param %q must be a valid string: %s", queryParam, err.Error()), | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never throw an error in practice, but it felt weird ignoring the error.
for k := range searchValues { | ||
if len(searchValues[k]) > 1 { | ||
return nil, []codersdk.ValidationError{ | ||
{ | ||
Field: "q", | ||
Detail: fmt.Sprintf("Query parameter %q provided more than once, found %d times", k, len(searchValues[k])), | ||
}, | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now enforced by the parser function. So the parser can decide on a query param basis if more than 1 value is allowed.
All default behavior remains as the underlying parsers require 1 value.
GitHub does this in their label search. Including this for an upcoming feature where the csv format is a bit unwieldy.
061909b
to
3fe88c4
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
GitHub does this in their label search. Including this for an upcoming feature where the csv format is a bit unwieldy.
supporting: #10661
Previously we enforced each key to only be used once, I changed this to be decided in the parse function, later in the process. This works better because the parser has more context.
What this does
It allows syntax like this to search for 2 ids:
The old error is still there for params that do not support it.
Future work
We have things like
name:<workspace_name>
. It would be nice to allow this syntax there too. Currently we get this error: