Skip to content

fix(rpc): action with file#307

Open
arnaud-moncel wants to merge 2 commits into
mainfrom
fix/rpc/action-file
Open

fix(rpc): action with file#307
arnaud-moncel wants to merge 2 commits into
mainfrom
fix/rpc/action-file

Conversation

@arnaud-moncel
Copy link
Copy Markdown
Member

@arnaud-moncel arnaud-moncel commented May 20, 2026

Definition of Done

General

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Test manually the implemented changes
  • Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • Consider the security impact of the changes made

Note

Add file action result support to RPC datasource action execution

  • The RPC agent's ActionExecute route now detects File-type action results and builds a file-oriented HTTP response with encoded Content-Disposition, X-Forest-Action-Type, and optional X-Forest-Action-Response-Headers headers.
  • RpcClient#call_rpc gains a with_response flag that returns the raw Faraday::Response instead of just the body, enabling the RPC datasource collection to reconstruct file results from response headers.
  • The RPC schema emitted by the agent now includes an actions map per collection, exposing only scope, is_generate_file, static_form, description, and submit_button_label — form definitions and execute callbacks are omitted.
  • BaseAction now accepts static_form as a constructor argument and from_plain_object passes it through, so the attribute is correctly reflected when building actions from schema.

Macroscope summarized 37ae6bd.

@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 20, 2026

1 new issue

Tool Category Rule Count
qlty Structure Function with many parameters (count = 7): call_rpc 1


# 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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many parameters (count = 7): call_rpc [qlty:function-parameters]

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Base automatically changed from fix/rpc/action-response to main May 21, 2026 08:28
@arnaud-moncel arnaud-moncel force-pushed the fix/rpc/action-file branch 2 times, most recently from 682b89a to 48a1cdd Compare May 21, 2026 13:55
@arnaud-moncel arnaud-moncel changed the base branch from main to fix/rpc/action-form May 21, 2026 13:55
Comment thread packages/forest_admin_rpc_agent/lib/forest_admin_rpc_agent/agent.rb
@arnaud-moncel arnaud-moncel force-pushed the fix/rpc/action-file branch from 0fc8d1a to 78f0eaa Compare May 21, 2026 14:08
Base automatically changed from fix/rpc/action-form to main May 22, 2026 08:24
@arnaud-moncel arnaud-moncel force-pushed the fix/rpc/action-file branch from 74c7031 to ce32968 Compare May 22, 2026 09:00
@arnaud-moncel arnaud-moncel force-pushed the fix/rpc/action-file branch from ce32968 to 37ae6bd Compare May 22, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant