Open hendaniel opened 4 months ago
After digging in, it seems that the issue is potentially this piece of code, line 300 in lib/sailthru.js:
json_payload_to_log = json_payload;
This appears to cause both variables to point to the same spot in memory, which means that when the following for/in loop runs immediately afterward....
for (param in binary_data) {
value = binary_data[param];
json_payload[param] = value;
json_payload_to_log[param] = '[TRUNCATED]';
}
... the payload's file data is simply changed to a string value of '[TRUNCATED]'
rather than the actual file object which needs to be passed. The signature hash itself is valid, but the invalid file format is throwing this error on the Sailthru backend for whatever reason. Changing the above variable definition to json_payload_to_log = this._json_payload(data)
appears to completely remedy this issue.
Thanks for looking into this! I'll be on the lookout for the fix release. We are also dealing with the JavaScript memory issue that was addressed in v5.0.1, so any updates would be greatly appreciated.
Description
When attempting to make a POST request using the
apiPost
function with multipart/form-data in Node.js 18.16.1 and usingsailthru-client
version 5.0.1, I encounter a signature hash mismatch error. The error message returned is{"error":5,"errormsg":"Signature hash does not match"}
. This issue does not occur when usingsailthru-client
version 5.0.0.Steps to Reproduce
sailthru-client
version 5.0.1.apiPost
function with multipart/form-data.Expected Behavior
The API should successfully process the multipart POST request without returning a signature hash mismatch error.
Actual Behavior
The API call fails and returns the following error message:
{"error":5,"errormsg":"Signature hash does not match"}
. The error does not occur when downgrading tosailthru-client
version 5.0.0.Environment
sailthru-client
version 5.0.1 (error occurs)sailthru-client
version 5.0.0 (no error)