New issue
Advanced search Search tips

Issue 650245 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 631047



Sign in to add a comment

non proxied swarming API doesn't respect query params

Project Member Reported by kjlubick@google.com, Sep 26 2016

Issue description

What steps will reproduce the problem?
(1) Navigate to https://2365-bd022ad-tainted-kjlubick-dot-chromium-swarm-dev.appspot.com/newui/botlist?c=id&c=os&c=task&c=status&f=os%3AWindows&l=5&s=id%3Aasc
(2) log in, open Dev Tools and refresh the page.
(3) Look at the network request to https://2365-bd022ad-tainted-kjlubick-dot-chromium-swarm-dev.appspot.com/api/swarming/v1/bots/list?dimensions=os%3AWindows&limit=5
(4) Notice that it is https://paste.googleplex.com/5913464669208576, which includes bots that are not os:Windows and is not returning only 5 results.

You may notice the UI seems to be showing only Windows bots - this is because it filters client side as well.




 

Comment 1 by no...@chromium.org, Sep 26 2016

Owner: no...@chromium.org
Status: Started (was: Untriaged)
hm, a resource container is supposed to be used with GET requests in https://cs.chromium.org/chromium/infra/luci/appengine/swarming/handlers_endpoints.py?q=endpoint+file:%5Einfra/luci/appengine/swarming/&sq=package:chromium&l=320

docs: https://cloud.google.com/appengine/docs/python/endpoints/create_api#using_resourcecontainer_for_path_or_querystring_arguments

but looks like Cloud Endpoints does not mind a message in GET requests. I can change the adapter to accept it too

Comment 2 by no...@chromium.org, Sep 26 2016

cloud endpoints silently ignores query string parameter if this value is already present in request body. gross

Comment 3 by no...@chromium.org, Sep 26 2016

cloud endpoints silently ignores URL path parameter if it is present in request body

curl -X PUT https://cr-buildbucket-dev.appspot.com/_ah/api/buildbucket/v1/builds/9000428170515905216/retry?tags=x:y --data '{"id":1}' -H "Content-Type: applica
tion/json"
{
 "error": {
  "message": "Build 1 not found",
  "reason": "BUILD_NOT_FOUND"
 },
 "kind": "buildbucket#resourcesItem",
 "etag": "\"c-RgmKx2yA5Oax82ub_lSFN0Vss/4KLd_EpgywIfdgooqK_APWoCCqU\""
}

grooooooooss

Comment 4 by no...@chromium.org, Sep 26 2016

Owner: mar...@chromium.org
Status: Assigned (was: Started)
I am hesitant to implement these bugs in the adapter. I'd rather fix swarming to use resource container for GET request handlers. M-A, thoughts?

Comment 5 by mar...@chromium.org, Sep 27 2016

You mean put everything in the URL path? That means creating a new API version.

Comment 6 by no...@chromium.org, Sep 27 2016

Owner: no...@chromium.org
Status: Started (was: Assigned)
no need for breaking changes. If you use ResourceContainer with same fields instead of subclass of message.Message, the adapter will start working. Also that's the recommended practice for query string parameters (which means, for all GET request handlers), see docs list above.

however, it would involve code duplication: you reuse swarming_rpcs.TaskRequest and defining a resource container with same fields would not be nice.

i am ok supporting a message.Message subclass only for GET requests. This will fix this particular problem and won't introduce ambiguity that Cloud Endpoints (because there is no request body). I will do it tomorrow.
Project Member

Comment 7 by sheriffbot@chromium.org, Sep 27 2016

Labels: Hotlist-Google

Comment 8 by no...@chromium.org, Sep 28 2016

Labels: -Pri-3 Pri-2
https://codereview.chromium.org/2370413002
the botlist and tasklist apis seem to now respect query params. 

However, /bot/[id]/tasks and /bot/id/events don't seem to respect their query params, neither fields= nor limit=

Comment 11 by no...@chromium.org, Oct 26 2016

Status: Fixed (was: Started)
yes, fields parameter is not supported by https://cs.chromium.org/chromium/infra/luci/appengine/components/components/endpoints_webapp2.py ATM, see below

limit works though:
curl https://chromium-swarm.appspot.com/_ah/api/swarming/v1/bot/build1-b4/events?limit=1 -H "Authorization: Bearer `authutil token`"
returns one event

I am closing this bug because proxied swarming API respects query params. The fields parameter is special, implemented inside google api guts. I considered supporting it, but the syntax of fields is not publicly documented and quite involved, e.g. it includes attribute filters.

If `fields` parameter is a big deal, consider filing a separate bug.

Comment 12 by no...@chromium.org, Oct 27 2016

Status: Started (was: Fixed)
limit does not work indeed, my example has _ah and i meant to test without it

Comment 14 by no...@chromium.org, Nov 11 2016

Status: Fixed (was: Started)

Sign in to add a comment