integration-platform-example icon indicating copy to clipboard operation
integration-platform-example copied to clipboard

Node.js example suggests JSON.stringify which will modify UTF-8 characters

Open mrcljx opened this issue 2 years ago • 0 comments

Environment

Node.js 18

Steps to Reproduce

  1. Implemented integration following TS example.
    function getSignatureBody(req: Request): string {
     const stringifiedBody = JSON.stringify(req.body);
     // HACK: This is necessary since express.json() converts the empty request body to {}
     return stringifiedBody === '{}' ? '' : stringifiedBody;
    }
    
  2. User with special character in their name couldn't use "Create Issue" integration (401)
  3. Reason was a signature mismatch.
  4. Raw JSON payload ended in
    {/* ... */,"actor":{"type":"user","id":1,"name":"John Do\\u00e9"}}
    

Expected Result

Signature match.

Actual Result

Signature did not match.

Analysis

Calling JSON.stringify replaces \u00e9 with é.

mrcljx avatar Mar 24 '23 15:03 mrcljx