{"record":{"id":"6f9c932a28af77a5","repo":"appsmithorg/appsmith","slug":"pe-jsn-4000","errorCode":"PE-JSN-4000","errorMessage":"Malformed JSON: {}","messagePattern":"Malformed JSON: (.+?)","errorType":"error_code","errorClass":"AppsmithPluginException","httpStatus":500,"severity":"error","filePath":"app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/restApiUtils/helpers/DataUtils.java","lineNumber":142,"sourceCode":"    public Object parseJsonBody(Object body) {\n        try {\n            if (body instanceof String) {\n                // Setting the requestBody to an empty byte array here\n                // since the an empty string causes issues with a signed request.\n                // If the content of the SignableRequest is null, the query string parameters\n                // will be encoded and used as the contentSha256 segment of the canonical request string.\n                // This causes a SignatureMatch Error for signed urls like those generated by AWS S3.\n                // More detail here - https://github.com/aws/aws-sdk-java/issues/2205\n                if (\"\" == body) {\n                    return new byte[0];\n                }\n                Object objectFromJson = objectFromJson((String) body);\n                if (objectFromJson != null) {\n                    body = objectFromJson;\n                }\n            }\n        } catch (JsonSyntaxException | ParseException e) {\n            throw new AppsmithPluginException(\n                    AppsmithPluginError.PLUGIN_JSON_PARSE_ERROR, body, \"Malformed JSON: \" + e.getMessage());\n        }\n        return body;\n    }\n\n    public String parseFormData(List<Property> bodyFormData, Boolean encodeParamsToggle) {\n        if (bodyFormData == null || bodyFormData.isEmpty()) {\n            return \"\";\n        }\n\n        return bodyFormData\n                // Disregard keys that are null\n                .stream()\n                .filter(property -> property.getKey() != null)\n                .map(property -> {\n                    String key = property.getKey();\n                    String value = (String) property.getValue();\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/restApiUtils/helpers/DataUtils.java#L124-L160","documentation":"Thrown by DataUtils.parseJsonBody when objectFromJson((String) body) raises JsonSyntaxException (Gson) or ParseException (Appsmith's own). This path handles the application/json content type: the raw body string is parsed into a Map or List; if the JSON is syntactically invalid the error is wrapped as PLUGIN_JSON_PARSE_ERROR with the offending body and the parser's message.","triggerScenarios":"An API action whose body content type is JSON but whose text is not valid JSON: unquoted keys, trailing commas, single quotes, unescaped control characters, a mustache template that evaluated to malformed JSON at runtime, or a body that was never meant to be JSON but whose Content-Type header says application/json.","commonSituations":"User writes {{input1.value}} which renders as undefined or empty, producing {}-less JSON; mixing JS expression syntax into JSON; copy/pasting a JS object literal instead of JSON; Content-Type auto-set to JSON for a raw text body.","solutions":["Validate the body with a JSON linter (e.g. jq, jsonlint.com) before running the action.","If the body uses mustache bindings, check the evaluated preview in the response panel and ensure each binding resolves to valid JSON fragments.","Switch the Content-Type to text/plain or raw if the body is not actually JSON.","Quote all string keys and values, remove trailing commas, and use double quotes throughout."],"exampleFix":"// before\n{\n  name: {{user.name}},   // unquoted key + raw binding\n}\n\n// after\n{\n  \"name\": \"{{user.name}}\"\n}","handlingStrategy":"validation","validationCode":"import com.fasterxml.jackson.databind.ObjectMapper;\nObjectMapper mapper = new ObjectMapper();\nString bodyStr = (String) body;\ntry {\n    mapper.readTree(bodyStr);\n} catch (Exception ex) {\n    throw new IllegalArgumentException(\"Request body is not valid JSON: \" + ex.getMessage(), ex);\n}\n// now safe to call dataUtils.parseJsonBody(body)","typeGuard":"public static boolean isValidJson(String s) {\n    try {\n        new ObjectMapper().readTree(s);\n        return true;\n    } catch (Exception e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    Object parsed = dataUtils.parseJsonBody(body);\n} catch (AppsmithPluginException e) {\n    if (e.getError() == AppsmithPluginError.PLUGIN_JSON_PARSE_ERROR) {\n        // fall back to sending the raw string or surface a user message\n        throw new IllegalArgumentException(\"Fix the JSON body: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Lint JSON bodies before running the action.","Double-check mustache bindings render to valid JSON fragments.","Set the Content-Type correctly - use text/plain for non-JSON bodies."],"tags":["json","rest-api","parse-error","request-body","mustache"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}