Fix script execution API error when data and config are sent as JSON arrays#8847
Open
sanjacornelius wants to merge 1 commit into
Open
Fix script execution API error when data and config are sent as JSON arrays#8847sanjacornelius wants to merge 1 commit into
sanjacornelius wants to merge 1 commit into
Conversation
Replace repeated json_decode(...) ?: [] usage with a private getRequestArray method. This centralizes request parsing for 'data' and 'config' in preview and the script execution flow, allowing the controller to accept either arrays or JSON strings and default safely to an empty array, reducing duplication and improving robustness.
|
Contributor
|
QA server K8S was successfully deployed https://ci-2f81f47e90.engk8s.processmaker.net |
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.





Issue & Reproduction Steps
Executing a script through the API using the documented JSON payload format results in a server error.
Example request:
When calling POST /api/1.0/scripts/execute/{script_id} (or the script preview endpoint) with an application/json request body, Laravel automatically parses the payload, causing data and config to be returned as arrays. The controller was always calling json_decode() on these values, assuming they were JSON strings, which results in the following error:
json_decode(): Argument #1 ($json) must be of type string, array givenThis behavior is incompatible with the API documentation, which defines both data and config as arrays.
Solution
Added a private
getRequestArray()helper toScriptControllerand updated bothexecute()andpreview()to use it when processing data and config.The helper normalizes request values by:
This allows both JSON and form-encoded requests to be handled consistently while preserving existing behavior.
How to Test
POST /api/1.0/scripts/execute/{script_id}with the following payload:
json_decode()TypeError is thrown.data=[{}]&config=[{}]) to confirm backward compatibility.Related Tickets & Packages
ci:deploy
Code Review Checklist