fix(rpc): action with file#307
Open
arnaud-moncel wants to merge 2 commits into
Open
Conversation
1 new issue
|
|
|
||
| # rubocop:disable Metrics/ParameterLists | ||
| def call_rpc(endpoint, caller: nil, method: :get, payload: nil, symbolize_keys: false, if_none_match: nil) | ||
| def call_rpc(endpoint, caller: nil, method: :get, payload: nil, symbolize_keys: false, |
| name: CGI.unescape(file_name_header.to_s), | ||
| stream: response.body.to_s | ||
| } | ||
| result[:response_headers] = JSON.parse(response_headers_header) if response_headers_header |
There was a problem hiding this comment.
🟢 Low forest_admin_datasource_rpc/collection.rb:198
When response_headers_header is an empty string or invalid JSON, JSON.parse raises JSON::ParserError and crashes action execution. The condition if response_headers_header is truthy for empty strings, so an absent or malformed header causes a hard failure rather than graceful fallback.
- result[:response_headers] = JSON.parse(response_headers_header) if response_headers_header🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file packages/forest_admin_datasource_rpc/lib/forest_admin_datasource_rpc/collection.rb around line 198:
When `response_headers_header` is an empty string or invalid JSON, `JSON.parse` raises `JSON::ParserError` and crashes action execution. The condition `if response_headers_header` is truthy for empty strings, so an absent or malformed header causes a hard failure rather than graceful fallback.
Evidence trail:
packages/forest_admin_datasource_rpc/lib/forest_admin_datasource_rpc/collection.rb lines 188-201 at REVIEWED_COMMIT: `response_headers_header` set from `response.headers['x-forest-action-response-headers']` (line 189), guard on line 198 `if response_headers_header` is truthy for empty strings in Ruby, `JSON.parse("")` raises `JSON::ParserError`. Ruby semantics: only `nil` and `false` are falsy; empty string is truthy.
682b89a to
48a1cdd
Compare
0fc8d1a to
78f0eaa
Compare
74c7031 to
ce32968
Compare
ce32968 to
37ae6bd
Compare
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.
Definition of Done
General
Security
Note
Add file action result support to RPC datasource action execution
ActionExecuteroute now detectsFile-type action results and builds a file-oriented HTTP response with encodedContent-Disposition,X-Forest-Action-Type, and optionalX-Forest-Action-Response-Headersheaders.RpcClient#call_rpcgains awith_responseflag that returns the rawFaraday::Responseinstead of just the body, enabling the RPC datasource collection to reconstruct file results from response headers.actionsmap per collection, exposing onlyscope,is_generate_file,static_form,description, andsubmit_button_label— form definitions and execute callbacks are omitted.BaseActionnow acceptsstatic_formas a constructor argument andfrom_plain_objectpasses it through, so the attribute is correctly reflected when building actions from schema.Macroscope summarized 37ae6bd.