Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(facebook): map five recurring Graph API rejections instead of "Unknown Error"

Gilad Resisi70499563d200
diff --git a/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts b/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
index fff046d02..fa911f328 100644
--- a/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts
@@ -64,7 +64,7 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
status: number
):
| {
- type: 'refresh-token' | 'bad-body';
+ type: 'refresh-token' | 'bad-body' | 'retry';
value: string;
}
| undefined {
@@ -229,6 +229,43 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
value: 'Facebook return: No permission to publish the video',
};
}
+ if (body.indexOf('"error_subcode":459') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value:
+ 'Facebook is asking you to resolve a security check. Log in at facebook.com, complete it, then try again',
+ };
+ }
+ if (body.indexOf('"error_subcode":492') > -1) {
+ return {
+ type: 'bad-body' as const,
+ value:
+ 'Your Facebook user no longer has a role on this Page. Ask a Page admin to grant you a role, then reconnect the channel',
+ };
+ }
+ if (body.indexOf('must be granted before impersonating') > -1) {
+ return {
+ type: 'refresh-token' as const,
+ value:
+ 'Facebook Page permissions are missing, please reconnect the channel and allow all permissions',
+ };
+ }
+ if (
+ body.indexOf('"error_subcode":33') > -1 &&
+ body.indexOf('does not exist') > -1
+ ) {
+ return {
+ type: 'bad-body' as const,
+ value:
+ 'The Facebook Page or post this was targeting no longer exists, please reconnect the channel and schedule again',
+ };
+ }
+ if (body.indexOf('Sorry, something went wrong') > -1) {
+ return {
+ type: 'retry' as const,
+ value: 'Facebook is temporarily unavailable, please try again later',
+ };
+ }
if (body.indexOf('490') > -1) {
return {
type: 'refresh-token' as const,