Troubleshooting Guide
Solutions for common Meta integration issues, backend crashes, and redirection errors.
Backend Dependencies Exception
Issue
NestJS fails to start with UnknownDependenciesException on Role or TenantMembership.
Root Cause
Circular file-level imports between entities (Role <-> TenantMembership).
Resolution
Switch the relationship definition to use string references instead of classes.
Technical Reference
@ManyToOne('Role', (role: any) => role.memberships) // Use string 'Role'Meta OAuth Mismatch
Issue
Facebook error: "redirect_uri is not identical to the one used in the OAuth dialog request".
Root Cause
The JS SDK (FB.login) uses a different implicit URI than our backend exchange request.
Resolution
Use a manual window.open popup to the Facebook dialog URL to explicitly set the redirect_uri.
Technical Reference
const fbUrl = `https://www.facebook.com/v19.0/dialog/oauth?client_id=${id}&redirect_uri=${encodedUri}...`;Missing Permission (#100)
Issue
The /me/businesses endpoint fails with a permission error even after granting scopes.
Root Cause
Restricted access to the business listing endpoint for certain account types.
Resolution
Use the debug_token endpoint to extract the WABA ID directly from granular_scopes fallback.
Technical Reference
const wabaId = debugData.granular_scopes.find(s => s.scope === 'whatsapp_business_management').target_ids[0];404 After Meta Callback
Issue
Redirecting to /dashboard after login results in a "Page Not Found" error.
Root Cause
The app requires a workspace slug in the URL which was missing from the redirect path.
Resolution
Use the state parameter in the OAuth flow to carry the tenant ID and redirect back to the workspace settings.
Technical Reference
localStorage.setItem('x-tenant-id', state); router.push('/settings/whatsapp');Infrastructure Best Practices
- Always use v19.0 for Meta Graph API calls to ensure consistency.
- Ensure
META_REDIRECT_URIis set tohttps://app.aimstore.in/meta/callback. - Validate all IDs (WABA, Phone) are trimmed of whitespace before storage.