twilio / twilio-node

Node.js helper library
MIT License
1.4k stars 510 forks source link

_.template on message.js (possibly other places) doesn't work #649

Closed RakeshKulangara closed 3 years ago

RakeshKulangara commented 3 years ago

Issue Summary

We've been scratching our head in figuring out a JSON error from Twilio when trying to send an SMS using twilioClient.messages.create, After a bit of debugging we figured twilio was sending a http error back.

<head><title>400 Bad Request</title></head>

this was caused by URL being https://api.twilio.com/2010-04-01/Accounts/<%= accountSid %>/Messages.json, for strange reasons, the accountSid is not not supplanted.

Further looking at the code in node_modules/twilio/lib/rest/api/v2010/account/message.js, we made a few debug logs to see what's going on.

Code Snippet

console.log("message.js ", MessageListInstance._solution); MessageListInstance._uri = _.template( '/Accounts/<%= accountSid %>/Messages.json' // jshint ignore:line )(MessageListInstance._solution); console.log("message.js ", MessageListInstance._uri)

It looks like the _.tempate code doesn't work (This happens in could of our production servers, but not everywhere, which is puzzling given, node, npm and code are exactly the same)

Here is the log line from above, clearly the accountSid variable has proper value.

message.js { accountSid: 'AC036bcblah' } message.js /Accounts/<%= accountSid %>/Messages.json

Steps to Reproduce

This is a pretty straightforward issue when it doesn't work, unfortunately seems to behave differently in different hosts.

Technical details:

Any pointers on how to proceed from here is highly appreciated.

NOTE: Updated twilio npm and issue went away, I can see that templating has been removed.

shwetha-manvinkurke commented 3 years ago

Hi @RakeshKulangara,

Thanks for taking time to look into the issue. You are right, the templating logic was replaced with interpolation in this commit on version 3.31. Let us know if you face any issues with the latest release.