Actions
Bug #21893
closedGET /docker/api/v2/containers returns SQL error when sending optional compute_resource_id
Difficulty:
Triaged:
Bugzilla link:
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1466240
Description of problem:
- With compute_resource_id
> $ curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET -d '{"compute_resource_id": 1}' https://sat6.com/docker/api/v2/containers > { > "error": {"message":"PG::Error: ERROR: argument of WHERE must be type boolean, not type integer\nLINE 1: SELECT \"containers\".* FROM \"containers\" WHERE (1) LIMIT 20 ...\n ^\n: SELECT \"containers\".* FROM \"containers\" WHERE (1) LIMIT 20 OFFSET 0"} > }
- Without compute_resource_id
> $ curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET https://sat6.com/docker/api/v2/containers > { > "total": 0, > ... > }
production log:
> 2017-06-29 04:42:18 a4fb040e [app] [I] Started GET "/docker/api/v2/containers" for 10.36.116.61 at 2017-06-29 04:42:18 -0400 > 2017-06-29 04:42:18 a4fb040e [app] [I] Processing by Api::V2::ContainersController#index as JSON > 2017-06-29 04:42:18 a4fb040e [app] [I] Parameters: {"compute_resource_id"=>1, "apiv"=>"v2", "container"=>{"compute_resource_id"=>1}} > 2017-06-29 04:42:18 a4fb040e [app] [I] Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_docker-3.1.0/app/views/api/v2/containers/index.json.rabl within api/v2/layouts/index_layout (4.1ms) > 2017-06-29 04:42:18 a4fb040e [app] [W] Action failed > | ActiveRecord::StatementInvalid: PG::Error: ERROR: argument of WHERE must be type boolean, not type integer > | LINE 1: SELECT "containers".* FROM "containers" WHERE (1) LIMIT 20 ... > | ^ > | : SELECT "containers".* FROM "containers" WHERE (1) LIMIT 20 OFFSET 0
Version-Release number of selected component (if applicable):
- katello-3.4.1-1.el7sat.noarch
- foreman-1.15.1-1.el7sat.noarch
- satellite-6.3.0-16.0.beta.el7sat.noarch
- tfm-rubygem-foreman_docker-3.1.0-1.fm1_15.el7sat.noarch
- tfm-rubygem-docker-api-1.28.0-2.el7sat.noarch
How reproducible:
Always
Steps to Reproduce:
1. curl -s -H "Content-Type: application/json" -H "Accept:application/json" -k -u "admin:changeme" -X GET -d '{"compute_resource_id": 1}' http://localhost:3000/docker/api/v2/containers
2.
3.
Actual results:
SQL error
Expected results:
Containers should be listed
Actions