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
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 collection and agent route
Collection#executein collection.rb to request the rawFaraday::Response(viawith_response: true) and detectX-Forest-Action-Type: Fileheaders, returning a structured File result hash with mime type, filename, optional response headers, and stream.RpcClient#call_rpcwith_responsekeyword argument so callers can receive the raw response object instead of the parsed body.ActionExecute#handle_requestin action_execute.rb to detect File results and build a response withContent-Disposition,X-Forest-Action-Type, and related headers before streaming the file content.executenow returnsresponse.body(instead of the parsed hash) for non-file actions, sincecall_rpcis called withwith_response: true.Macroscope summarized 74c7031.