fix(SUPPORT-14907): improve error logging when page token lookup fails#125
Closed
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
Closed
Conversation
Fixes Facebook Pages API v2 returning 400/403 errors for post_insights requests using insights.since(now).metric(...). Root cause: Facebook returns paging.next URLs with Unix timestamps pointing to the future, which fail with error: '(#100) since param is not valid. Metrics data is available for the last 2 years.' Changes: - Add parse-unix-ts helper to parse 10-digit Unix timestamps - Add extract-url-param helper to extract query params from URLs - Add remove-url-param helper to remove query params from URLs - Add handle-future-timestamps to process pagination URLs: - If both since and until are in future -> skip (end of data) - If only until is in future -> remove it, API uses 'now' implicitly - Update get-next-page-url to use handle-future-timestamps This fix is similar to the one applied in component-meta PR #19 for Instagram insights. Co-Authored-By: Zora Jelínková <zora.jelinkova@keboola.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Previously, exceptions during page token lookup were silently swallowed, causing the component to fall back to user token without any indication of what went wrong. This led to confusing 403 Forbidden errors when the user token lacked permissions for page insights. Changes: - Replace swallow-exceptions macro with try-with-warning that logs errors - Add detailed error message when both /me/accounts and page details fail - Only attempt page details API if accounts list lookup didn't find token - Improve logging to help diagnose token permission issues Co-Authored-By: Zora Jelínková <zora.jelinkova@keboola.com>
Per user request, removing the future timestamp handling code as it was not the correct fix for SUPPORT-14907. The actual issue is related to page token lookup failures, which is addressed by the token logging fix in query.clj. Co-Authored-By: Zora Jelínková <zora.jelinkova@keboola.com>
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.
Summary
Fixes visibility into Facebook Pages API v2 returning 403 errors for post_insights requests by improving error logging during page token lookup.
Root cause: The
swallow-exceptionsmacro was silently catching all exceptions during page token lookup, causing the component to fall back to user token without any indication of what went wrong. This led to confusing 403 Forbidden errors when the user token lacked page-level permissions.Changes in
query.clj:swallow-exceptionsmacro withtry-with-warningthat logs errors/me/accountsand page details API failNow when page token lookup fails, you'll see messages like:
"Warning: fetching accounts list for page X failed: 403 Forbidden""Page token failed for X: both /me/accounts and page details API failed. The user token will be used but may lack permissions for insights queries."Review & Testing Checklist for Human
Recommended test plan:
runtime.tagconfigurationNotes
Important: This fix improves visibility into token lookup failures but does not automatically resolve permission issues. If the user's token lacks the required permissions (e.g.,
pages_read_engagement,read_insights), the extraction will still fail - but now with clear error messages explaining why.https://keboola.atlassian.net/browse/SUPPORT-14907
Link to Devin run: https://app.devin.ai/sessions/17f4b3f016a7446f8f4e6bbf7a8c8e14
Requested by: Zora Jelínková
Release Notes
Justification, description
Improve error logging when page token lookup fails in Facebook Pages API v2, making it easier to diagnose 403 Forbidden errors.
Plans for Customer Communication
N/A
Impact Analysis
Low risk - logging-only change:
Deployment Plan
N/A
Rollback Plan
N/A
Post-Release Support Plan
N/A