fix(rpc): action with file#307
Open
arnaud-moncel wants to merge 1 commit 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.
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 response support to RPC action execution
Collection#executein the RPC datasource now passeswith_response: trueto get the rawFaraday::Response, then checks theX-Forest-Action-Typeheader to detect file responses and builds a structured result with type, mime type, filename, stream, and optional response headers.RpcClient#call_rpcgains awith_responsekeyword argument; when true, returns the rawFaraday::Responseinstead of the parsed body.ActionExecute#handle_requestin the RPC agent detects file results and converts them into a proper HTTP response withContent-Disposition,Content-Type,X-Forest-Action-Type, and optionallyX-Forest-Action-Response-Headers.CGI.unescapeon the datasource side.📊 Macroscope summarized ab5c583. 3 files reviewed, 3 issues evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues