Project

General

Profile

Actions

Bug #35591

closed

Can't use 'search' with fact_value via API

Added by Adam Winberg over 1 year ago. Updated over 1 year ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Trying to get a fact value via API fails with:

https://<foremanhost>/api/fact_values/?search=name=myfact+and+host=lxserv1638
{
  "error": {"message":"Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs."}
}

production.log on Foreman server:

2022-10-04T07:54:50 [I|app|4a5a7802] Started GET "/api/fact_values/?search=name=myfact+and+host=lxserv1638" for 10.65.1.80 at 2022-10-04 07:54:50 +0000
2022-10-04T07:54:50 [I|app|4a5a7802] Processing by Api::V2::FactValuesController#index as JSON
2022-10-04T07:54:50 [I|app|4a5a7802]   Parameters: {"search"=>"name=myfact and host=lxserv1638", "apiv"=>"v2"}
2022-10-04T07:54:50 [I|app|4a5a7802] Authorized user foremanread(foremanread)
2022-10-04T07:54:51 [W|app|4a5a7802] Action failed
2022-10-04T07:54:51 [I|app|4a5a7802] Backtrace for 'Action failed' error (ActiveModel::MissingAttributeError): missing attribute: fact_name_id
 4a5a7802 | /usr/share/gems/gems/activemodel-6.1.6.1/lib/active_model/attribute.rb:222:in `value'
 4a5a7802 | /usr/share/gems/gems/activemodel-6.1.6.1/lib/active_model/attribute_set/builder.rb:55:in `block in fetch_value'
 4a5a7802 | /usr/share/gems/gems/activemodel-6.1.6.1/lib/active_model/attribute_set/builder.rb:46:in `fetch'
...

If I turn on sql debugging and run the sql query written to the logs I get a correct response.
If I impersonate the user used to do the API request and do the same fact search in the GUI I get the correct response.

This has worked before, but not sure when it stopped working.


Related issues 3 (1 open2 closed)

Related to Foreman - Bug #31897: Headline api feature per_page=all doesn't work for all resourcesNewActions
Related to Foreman - Refactor #34160: Improve the fact_values api performance when loading a large number of factsClosedTomer BriskerActions
Is duplicate of Foreman - Bug #35990: Parameter 'search' on fact_value API endpoint results in internal server errorClosedNofar AlfassiActions
Actions

Also available in: Atom PDF