AutomaApp / automa

A browser extension for automating your browser by connecting blocks
https://www.automa.site
Other
11.41k stars 1.23k forks source link

Is there a limitation for replacedValue length? #1650

Closed MaChao-Trip closed 7 months ago

MaChao-Trip commented 7 months ago

Describe the bug I assign a variable with a long value, and see it's correct in debug mode, but when I want to send it in the request body of the http post request, the log shows the replaced variable seems like to be trimed.

To Reproduce Steps to reproduce the behavior:

  1. assign a variable with a long value in a JavaScript block.
    automaSetVariable('payload', '{"SearchCriteria":{"OrigDestRequest":[{"Date":"2024-04-25 00:00:00","ORIG":"GLA","DEST":"LGW","ORIGType":0,"DESTType":1},{"Date":"2024-05-01 00:00:00","ORIG":"LGW","DEST":"GLA","ORIGType":1,"DESTType":0}],"TravelerRequest":[{"AgeType":"ADT","TravelerCount":1,"Nationality":""}],"ValidatingCarrier":[],"CabinClass":["Y"],"ExtensionOption":[{"Key":"SupportNewBaggage","Value":"true"},{"Key":"EngineControl","Value":"AAA-AA,,,|"}],"Currency":"USD","Language":"","ResultControl":{"DirectControlType":0}},"SearchContext":{}}');
    automaNextBlock()
  2. Send it in a http post request body
    {
    "id": "0",
    "request1": {{variables@payload}}
    }
  3. the log shows like below, the varibale payload is correct in referenceData section but seems like to be trimed in replacedValue
    "replacedValue": {
    "{{variables@payload}}": "{\"SearchCriteria\":{\"OrigDestRequest\":[{\"Date\":\"2024-04-25 00:00:00\",\"ORIG\":\"GLA\",\"DEST\":\"LGW\",\"ORIGType\":0,\"DESTType\":1},{\"Date\":\"2024-05-01 00:00:00\",\"ORIG\":\"LGW\",\"DEST\":\"GLA\",\"ORIGType\":1,\"DESTType\":0}],\"TravelerRequest\":[{\"AgeType\":\"ADT\",\"TravelerCount\":1,\"Nationality\":\"\"}],\"ValidatingCarrier\":[],\"CabinClass\":[\"Y\"],\"ExtensionOption\":[{\"Key\":\"SupportNewBaggage\",\"Value\":\"true\"},{\"Key\":\"EngineControl\",\"Value\":\"AAA-AA,,,|\"}],\"Currency\":\"USD\",\"Language\":\"\",\"ResultControl\":{\"DirectControlType\":0}},\"SearchConte"
    }

    Expected behavior varibale payload in the replacedValue is the same as referenceData

Desktop (please complete the following information):

In addition, I found something is probably the cause to this issue: https://github.com/AutomaApp/automa/blob/1cedeb3b418a9b653fb7f8e519b7f71fe9695dee/src/workflowEngine/templating/mustacheReplacer.js#L132

Is the direct cause why the long replacedValue is trimmed? If it's true, why Automa splice the 512 characters when replacing value?