Project

General

Profile

Actions

Bug #13645

open

Scoped search fails with 500 on postgresql if value can't be converted

Added by Tomáš Strachota about 8 years ago. Updated over 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Search
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Scoped search fails with internal server error on postgresql if the searched value can't be converted to a type of the column it's compared against. This happens for example when the search query tries to compare empty string with integer column.

Reproducible with hammer:

hammer filter list --search 'role_id = ""'
hammer filter list --search 'role_id = a'

Results in:

PG::Error: ERROR:  invalid input syntax for integer: "a" 
LINE 1: ..."id" = "filters"."role_id" WHERE (("roles"."id" = 'a'))  ORD...
                                                             ^
: SELECT  "filters"."id" AS t0_r0, "filters"."search" AS t0_r1, "filters"."role_id" AS t0_r2, "filters"."created_at" AS t0_r3, "filters"."updated_at" AS t0_r4, "filters"."taxonomy_search" AS t0_r5, "roles"."id" AS t1_r0, "roles"."name" AS t1_r1, "roles"."builtin" AS t1_r2, "roles"."permissions" AS t1_r3 FROM "filters" LEFT OUTER JOIN "roles" ON "roles"."id" = "filters"."role_id" WHERE (("roles"."id" = 'a'))  ORDER BY filters.role_id, filters.id LIMIT 1000 OFFSET 0


Related issues 2 (0 open2 closed)

Related to Hammer CLI - Bug #13064: Executing "hammer role filters" command throws SQL errorsClosed01/08/2016Actions
Has duplicate Foreman - Bug #14235: Executing "hammer role filters" command throws SQL errorsDuplicate03/16/2016Actions
Actions #1

Updated by Tomáš Strachota about 8 years ago

  • Related to Bug #13064: Executing "hammer role filters" command throws SQL errors added
Actions #2

Updated by Shimon Shtein about 8 years ago

role_id filter parameter is set to string in api/v2/filters_controller.rb Probably needs change to integer. In addition we need to set validation in hammer-cli based on apipie type reported.

Actions #3

Updated by Dominic Cleal about 8 years ago

  • Has duplicate Bug #14235: Executing "hammer role filters" command throws SQL errors added
Actions #4

Updated by Brad Buckingham about 8 years ago

  • Bugzilla link set to 1296782
Actions #5

Updated by Bryan Kearney over 7 years ago

  • Status changed from New to Duplicate

Duplicate of 13064

Actions #6

Updated by Dominic Cleal over 7 years ago

  • Status changed from Duplicate to New

This isn't a duplicate, #13064 is filed against Hammer CLI and this is filed against Foreman's search feature. The server error is a valid bug report irrespective of a CLI fix.

Actions

Also available in: Atom PDF