-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix invalid token.xml template by adding closing slash to Pause tags #708
Fix invalid token.xml template by adding closing slash to Pause tags #708
Conversation
Thanks a lot for this important fix! Could you still explore any capability in Python XML libs to validate if the content is XML compliant (for some regression test)? |
Maybe something like:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #708 +/- ##
=======================================
Coverage 97.84% 97.84%
=======================================
Files 78 78
Lines 3384 3389 +5
Branches 384 384
=======================================
+ Hits 3311 3316 +5
Misses 42 42
Partials 31 31 ☔ View full report in Codecov by Sentry. |
Good point. It looks like we can do that with xml.etree.ElementTree.fromstring so I've added that in f071908. As you'll see, I typically just add a comment to reflect that it'll raise an exception if it fails, but if you have a preference for how to test that specific behavior I'm happy to update that. I confirmed that the test will fail if the unclosed tag is included in either press_a_key.xml or token.xml, and here is an example of that output for reference.
Or if you prefer it to be a separate test altogether that just checks the xml templates directly, I could do that instead. |
Thanks, that's what I had in mind! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
Thanks for the quick review! Is there a timeline for the next release? Just useful for planning purposes so no worries if there isn't one. |
No timeline for now. I guess you'll have to use the git master in the meantime. |
Description
In order for XML to be well formed, all elements must have closing tags. Currently, the token.xml template violates this with the unclosed <Pause> tags. As described under How Has This Been Tested, I came to the conclusion that the invalid token.xml template results in TwiML that Twilio is unable to parse when making phone calls.
This change was introduced in #488 as part of the 1.14.0 release almost two years ago, but I didn't see any open or closed issues related to the phone call functionality being broken which seemed surprising. I briefly looked through Twilio's changelog to see if there were any Twiml related changes that could explain why this might only be an issue with certain versions of Twilio, but nothing jumped out.
I'm admittedly optimistic that this is a straightforward change that is good to make regardless of how broad the impact is.
Motivation and Context
I'm in the process of upgrading a project I work on from v1.13.2 to v1.15.5, and encountered an error with the phone call method. The call is made successfully, but after pressing any key to continue, the response is "We're sorry. An application error has occurred. Good bye". After looking at the Twilio log for this call, I noticed that this tag is never closed and figured that might be the cause of the error, despite Twilio confirming that the POST request to
twilio/inbound/two_factor/<token>
was successful.How Has This Been Tested?
I pasted the following simplified xml into both Twilio's TwiML Bin and a regular XML validator as a sanity check, and both confirmed that the unclosed <Pause> tag was invalid, but updating to <Pause/> was valid.
Invalid
Valid
I also updated the automated test that verifies the generated XML is as expected.
Update: I was also able to test this on the project I'm upgrading and confirmed that this change resolves the error encountered with the phone call method.
Screenshots (if appropriate):
Types of changes
Checklist: