Legacy Dev Forum Posts

 View Only

Sign Up

Data action validation errors

  • 1.  Data action validation errors

    Posted 06-05-2025 18:41

    SajidAbbasMalek | 2019-09-05 06:29:01 UTC | #1

    Hi everyone,

    Not all of the fields of my data action are mandatory. When I try to test it (leaving an optional field empty) it gives below error.

    {

    "status": 400, "code": "invalid.substitution", "message": "Substitution values invalid in action config. Reference ${input.state} evaluated to null when attempting to render at BodyTemplate[line 8, column 15] A common reason for this error is needing to prepend the variable with 'input.' or 'credentials.'", "messageParams": {}, "contextId": "690526c8-7614-4eaa-8715-389cd9267e2b", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }

    which I guess corresponds to below line of code in body of my request.

    "state": "${input.state}",

    Anyways, to avoid it, I went on to make this input parameter in my contract as 'Nullable'. Now I get below error.

    {

    "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "d26c7b29-d793-4a21-87e8-629a4bc80f7e", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [ { "status": 400, "code": "BADREQUEST", "message": "Action DEVValidateAddress failed validation. Errors: [Failed Validation of contract.input.inputSchema as a simple properties schema. Must be an Object with properties and no sub-objects. JSON failed schema validation for the following reasons: Schema: # @/properties/properties/patternProperties/^[a-zA-Z][a-zA-Z0-9-]*$/properties/type. Error location: /properties/state/type. instance value ([\"string\",\"null\"]) not found in enum (possible values: [\"boolean\",\"integer\",\"null\",\"number\",\"string\"]),\nSchema: # @/properties/properties/patternProperties/^[a-zA-Z][a-zA-Z0-9-]*$/properties/type. Error location: /properties/state/type. instance type (array) does not match any allowed primitive type (allowed: [\"string\"])]", "messageParams": {}, "details": [], "errors": [] } ] }

    Which I believe is caused by below line of code which was added by GUI when I clicked on 'Nullable' checkbox.

    "state": {

    "type": [ "string", "null" ] }

    Any help? I am attaching an export of my data action.

    <a class="attachment" href="/forum/uploads/db6296/original/2X/2/21ef95c41620441d299db345b53d68d3fc841e77.json">DEVValidateAddress-20190905102825.custom.json</a> (3.0 KB)


    Jason_Mathison | 2019-09-05 12:28:12 UTC | #2

    Hi SajidAbbasMalek,

    Thanks for posting an export of your action. The issue is happening while the Data Action is trying to process your request template, so changing the acceptable types for the state variable won't do any good.

    There are a couple of ways to handle this. The first is to ensure that the state input is set to some sort of string. For example, with Architect you could set the input string for state to "" if you don't have a real value.

    The other option is to add a check inside of your request template. The top of this page gives an example of doing an if check on a variable to ensure that it is not null: http://people.apache.org/~henning/velocity/html/ch05s03.html

    For my testing, I changed the request template to this:

    "requestTemplate": "{\n \"validationType\": \"BILLTO\",\n \"billTo\": {\n \"firstName\": \"${input.firstName}\",\n \"lastName\": \"${input.lastName}\",\n \"street\": \"${input.street}\",\n \"city\": \"${input.city}\",\n \"state\": \"#if( ${input.state} )${input.state}#end\",\n \"postalCode\": \"${input.postalCode}\",\n \"country\": \"${input.country}\",\n \"emailId\": \"${input.emailId}\"\n }\n}"

    Note that I put the #if inside of the quotes for the state's value. That way if the value of the state variable is null the end result will be "".

    --Jason


    SajidAbbasMalek | 2019-09-05 13:09:14 UTC | #3

    Thanks @Jason_Mathison ,

    You are always helpful. I followed the advice and I was able to get my data action working but I wonder what has changed lately? I don't recall facing these validation errors earlier. I used to pass empty values in the testing before.

    Sajid


    Jason_Mathison | 2019-09-05 15:17:15 UTC | #4

    Hi Sajid,

    Ah, so you are saying that the behavior of the test UI has changed? I will look into that.

    --Jason


    system | 2019-10-06 15:17:18 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 5960