-
Notifications
You must be signed in to change notification settings - Fork 88
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
URGENT Crash Fix: Fixed crash caused by Facebook Beta Shopify Connector #119
URGENT Crash Fix: Fixed crash caused by Facebook Beta Shopify Connector #119
Conversation
- Facebook's beta connector introduced a null receipt in the transaction object from Shopify - This patch handles the null case for a receipt in a transaction, preventing a crash
Hi @kcharwood, thanks for your contribution! In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. |
You did it @kcharwood! Thank you for signing the Singer Contribution License Agreement. |
# Not all Shopify transactions have receipts. Facebook has been shown | ||
# to push a null receipt through the transaction | ||
receipt = transaction_dict.get('receipt', {}) | ||
if receipt: |
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.
This is really the only change in this PR. All the code below this is simply whitespace change from indenting the code under this if receipt
check.
def test_null_receipt_record(self): | ||
record = {"receipt": None} | ||
expected_record = {"receipt": None} | ||
canonicalize(record, "foo") | ||
self.assertEqual(record, expected_record) | ||
|
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.
Running this code against current master branch will yield a crash. Running it against this PR yields a success.
Hi Singer Team, Rachit here from the Facebook Shops team. I've been working directly with Kevin on this issue and can confirm that this is a blocker to their current Shopify orders integration with us. They're in a pretty bad state right now so the team and I would really appreciate it if you could take a look at this PR request ASAP to resolve Kevin's issues. cc @cmerrick |
This looks good. Thank you for letting us know. |
- Facebook's beta connector introduced a null receipt in the transaction object from Shopify - This patch handles the null case for a receipt in a transaction, preventing a crash
We are part of Facebook/Instagram's beta program for their connectors into Shopify. On Friday, part of our Facebook/Shopify integration was upgraded to their latest codebase. In this codebase, Facebook began sending
null
receipt data for all Shopifytransaction
objects. Note they weren't excluding thereceipt
key, but explicitly setting it tonull
This behavior led to a crash inside the
canonicalize
method in the Stitch Shopify connector, which has led our entire Shopify connector to be down since late Friday night in a crash loop.Description of change
The change here simply safely handles the case where the receipt could be
null
. In the past, the codebase assumed at a minimum that an empty ({}
) dictionary would exist for this key, or that thereceipt
key wouldn't exist at all, and was crashing when trying to access a key within the receipt when the receipt wasnull
. Now, there will be no operations when the receipt isnull
.I have added a test case explicitly showing the crash. If you run the test without my patch, you will see the crash. Running the test with my patch yields no crash.
QA steps
Risks
Minimum. Our entire reporting arm is down in our business until this is resolved, so urgency is extremely high for me to get this deployed today.
Rollback steps
Test
I created a test to demonstrate the issue. When running the test without my patch, it causes a crash. Running with my patch passes as expected.
Test without my patch:
Test with my patch: