Fix Facebook video analytics ID resolution#87
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df90b0515e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| except Exception as exc: | ||
| errors_by_post_id[post_id] = str(exc) | ||
| logger.warning("Facebook post insights failed at %s: %s", endpoint, exc) | ||
| continue |
There was a problem hiding this comment.
Do not swallow transient insight failures
When scheduled analytics hits a Facebook 429, transport error, or malformed JSON while fetching /insights, this broad catch handles RateLimitError/httpx/parse failures as if the candidate simply had no insights edge and eventually returns empty insight values. _sync_post_metrics relies on get_post_metrics raising for transient failures so it can skip the snapshot; returning a PostMetrics object instead can persist zero/partial reactions/engagement for that day instead of retrying later.
Useful? React with 👍 / 👎.
| except Exception as exc: | ||
| last_error = exc | ||
| break |
There was a problem hiding this comment.
Do not zero counts on transient field failures
When the object field lookup is rate-limited or fails at the transport/JSON layer, this new catch-all returns {} instead of propagating the transient error. In the analytics sync path that means comments, shares, and the reactions fallback are treated as zero (or omitted) while any successful insights can still be written, corrupting the post snapshot; only the Meta APIError cases used for unsupported fields should be handled here.
Useful? React with 👍 / 👎.
df90b05 to
4065d5c
Compare
What does this PR do?
Why?
How to test
Checklist
pytest)ruff check .andruff format --check .)