Fix script execution API error when data and config are sent as JSON arrays#8847
Open
sanjacornelius wants to merge 4 commits into
Open
Fix script execution API error when data and config are sent as JSON arrays#8847sanjacornelius wants to merge 4 commits into
sanjacornelius wants to merge 4 commits 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 |
- Update OpenAPI annotations in ScriptController to declare 'data' and 'config' as objects instead of arrays.
- Add getRequestArray() to normalize script inputs: decode JSON strings to arrays, detect list payloads and unwrap single-element list objects (e.g. [{}] or [{"key":"value"}) to an associative object, and return an empty array for unsupported forms. This prevents the script microservice from rejecting list-shaped payloads (422) and enforces consistent request shapes.
Contributor
|
QA server K8S was successfully deployed https://ci-2f81f47e90.engk8s.processmaker.net |
mcraeteisha
approved these changes
Jun 4, 2026
This reverts commit 85da842.
|
Contributor
|
QA server K8S was successfully deployed https://ci-2f81f47e90.engk8s.processmaker.net |
nolanpro
approved these changes
Jun 4, 2026
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 can result in a server error or an invalid request being sent to the script microservice.
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 callingjson_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 givenAdditionally, the API documentation defined data and config as arrays, while the script microservice expects object-shaped payloads. Requests containing list-shaped payloads such as:
or
could be forwarded to the script microservice and rejected with a
422 Unprocessable Entityresponse.Solution
Updated the request handling and API documentation to ensure script payloads are processed consistently regardless of request format.
Changes include:
ScriptControllerto declare data and config as objects instead of arrays, aligning the API documentation with the expected payload structure.getRequestArray()helper to normalize script inputs for bothexecute()andpreview().[{}]or[{"key":"value"}]) into associative objects before forwarding them to the script microservice.This ensures both JSON and form encoded requests are handled consistently, prevents
json_decode()type errors, avoids script microservice 422 responses caused by list shaped payloads, and aligns the implementation with the updated API documentation.How to Test
POST /api/1.0/scripts/execute/{script_id}with the following payload:
json_decode()TypeError is thrown.and verify the script microservice accepts the request without returning a 422 error.
8. Review the generated OpenAPI/Swagger documentation and confirm data and config are documented as objects.
Related Tickets & Packages
ci:deploy
Code Review Checklist