Treat 404-with-resources as success in action discovery - #10
Open
mraible wants to merge 1 commit into
Open
Conversation
The Fusion search_activities API returns a top-level HTTP 404 when a result set includes an action whose backing catalog artifact is missing, even though it still returns every action it could resolve. The unresolvable ids come back separately under body.errors; the usable actions are in body.resources, and meta.pagination.total reflects the full match count. The FalconPy migration keyed success off the aggregate status_code, so any non-200 discarded the valid resources and returned None (or raised). Because common searches (for example name:'email', which matches many actions) happen to include an orphaned entry, they returned a 404-with-results and looked like transient failures, forcing a fallback to the slow full-catalog scan or hardcoded ids. The earlier curl-based implementation read resources directly off the body and never gated on an aggregate status, so this is a regression introduced by the SDK migration. This is confirmed server-side, not a client issue: a raw HTTP request with no SDK in the path returns the same 404-with-results, and the SDK faithfully passes the status through. Add _usable_body(resp), which returns the response body whenever it carries resources regardless of the aggregate status, and only treats a non-200 with no resources as a real failure. Route _fql_search, _fetch_page_with_retry, list_actions, and get_action_details through it. Because the API places orphaned entries in errors rather than resources, they are naturally excluded from results. Adds a TestUsableBody class covering the 200, partial-404-with-resources, 404-without-resources, 500, and missing-body cases. Full test_action_search.py suite passes (16 tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Fusion
search_activitiesAPI returns a top-level HTTP 404 when a result set includes an action whose backing catalog artifact is missing, even though it still returns every action it could resolve. The unresolvable ids come back separately underbody.errors; the usable actions are inbody.resources, andmeta.pagination.totalreflects the full match count.The FalconPy migration keyed success off the aggregate
status_code, so any non-200 discarded the valid resources and returnedNone(or raised). Because common searches (for examplename:'email', which matches many actions) happen to include an orphaned entry, they returned a 404-with-results and looked like transient failures, forcing a fallback to the slow full-catalog scan or hardcoded action ids. The earlier curl-based implementation readresourcesdirectly off the body and never gated on an aggregate status, so this is a regression introduced by the SDK migration.This is confirmed server-side, not a client issue: a raw HTTP request with no SDK in the path returns the same 404-with-results, and the SDK faithfully passes the status through.
Fix
Add
_usable_body(resp), which returns the response body whenever it carriesresourcesregardless of the aggregate status, and only treats a non-200 with no resources as a real failure. Route_fql_search,_fetch_page_with_retry,list_actions, andget_action_detailsthrough it. Because the API places orphaned entries inerrorsrather thanresources, they are naturally excluded from results, no separate filtering needed.Testing
Adds a
TestUsableBodyclass covering the 200, partial-404-with-resources, 404-without-resources, 500, and missing-body cases. The fulltest_action_search.pysuite passes (16 tests) and pylint stays at 10.00/10.