Fix KeyError: 'fbtrace_id' for ActionSource.APP with SafeEventRequestAsync#723
Open
Fix KeyError: 'fbtrace_id' for ActionSource.APP with SafeEventRequestAsync#723
Conversation
…Async - Adds SafeEventRequestAsync wrapper to gracefully handle missing fbtrace_id in API responses when using ActionSource.APP. - Prevents crashes by returning a fallback EventResponse if fbtrace_id is missing. - No changes to core SDK files; this is a drop-in, non-breaking fix. - Includes test script to verify the patch. (Artifact 1. ID=[CNKG] Type=\"text\" Title=\"Facebook Python Business SDK: Solving KeyError 'fbtrace_id' with ActionSource.APP\")
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this PR do?
SafeEventRequestAsync) to handle theKeyError: 'fbtrace_id'that occurs when sending events withActionSource.APPin the Facebook Python Business SDK.fbtrace_id, the wrapper returns a safe fallback EventResponse, preventing crashes.Why is this needed?
When using
ActionSource.APP, the Facebook API sometimes omits thefbtrace_idfield, causing the SDK to raise aKeyErrorand crash. This patch ensures robust handling of this scenario.How to use