{"record":{"id":"bf1ada41c8213128","repo":"yikart/AiToEarn","slug":"channelplatformapifailed-bf1ada","errorCode":"ChannelPlatformApiFailed","errorMessage":"ChannelPlatformApiFailed","messagePattern":"ChannelPlatformApiFailed","errorType":"error_code","errorClass":"InstagramPlatformException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-publish.provider.ts","lineNumber":126,"sourceCode":"      const rawError = err instanceof InstagramPlatformException\n        && err.platformCause?.raw\n        && typeof err.platformCause.raw === 'object'\n        ? (err.platformCause.raw as { error?: { error_subcode?: number, fbtrace_id?: string } }).error\n        : undefined\n\n      if (!(err instanceof InstagramPlatformException) || rawError?.error_subcode !== 2207069) {\n        throw err\n      }\n\n      let limit: Awaited<ReturnType<InstagramService['getContentPublishingLimit']>> | undefined\n      try {\n        limit = await this.instagramService.getContentPublishingLimit(accessToken, igUserId)\n      }\n      catch (limitErr) {\n        this.logger.warn(limitErr, `Failed to fetch Instagram content publishing limit for ${igUserId}`)\n      }\n\n      throw new InstagramPlatformException({\n        code: ResponseCode.ChannelPlatformApiFailed,\n        category: PlatformErrorCategory.Quota,\n        context: {\n          ...err.context,\n          taskId: input.taskId,\n          accountId: input.accountId,\n        },\n        cause: {\n          type: err.platformCause?.type ?? PlatformErrorCauseType.Platform,\n          httpStatus: err.platformCause?.httpStatus,\n          platformCode: err.platformCause?.platformCode,\n          raw: err.platformCause?.raw,\n          quota: {\n            usage: limit?.quotaUsage,\n            total: limit?.quotaTotal,\n            durationSeconds: limit?.quotaDuration,\n            fbtraceId: rawError.fbtrace_id,\n          },","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-publish.provider.ts#L108-L144","documentation":"An Instagram Graph API publish attempt hit the platform content publishing quota (or the API call failed in a way mapped to the Quota category). Before rethrowing, the provider tried to fetch the content publishing limit for extra context; the original error is wrapped in InstagramPlatformException with ChannelPlatformApiFailed.","triggerScenarios":"publish() catches an error from the Graph API publish/container call, and (when the error is quota-related) fetches getContentPublishingLimit then throws InstagramPlatformException(ChannelPlatformApiFailed, category Quota) enriched with taskId/accountId context.","commonSituations":"Account exceeded Instagram's ~25-posts-per-24h / 50-api-calls-per-24h publishing limit; burst publishing of many scheduled tasks at once; shared IP throttling; Graph API returned code 4, 9004, or rate-limit subcodes.","solutions":["Read err.context and the publishing-limit data to confirm quota exhaustion","Back off and retry after the 24h window; spread scheduled tasks over time","Wait between container creation and publish calls (respect per-call rate limits)","If the account is a fresh/limited IG account, warm it up or publish fewer posts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check remaining quota before publishing\nconst limit = await instagramService.getContentPublishingLimit(accessToken, igUserId)\nif (limit.quota_total <= limit.quota_used) {\n  throw new Error('Instagram publishing quota exhausted; retry after window resets')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await provider.publish(input)\n} catch (e) {\n  if (e.code === 'ChannelPlatformApiFailed' && e.context?.category === 'quota') {\n    await scheduleRetry(input.taskId, { delayMs: 60 * 60 * 1000, maxAttempts: 3 })\n  } else throw e\n}","preventionTips":["Check the content publishing limit endpoint before each publish","Throttle scheduled posts per IG account (~25/24h)","Stagger burst campaigns instead of publishing simultaneously","Track quota consumption per accountId in your own scheduler"],"tags":["instagram","quota","rate-limit","publishing"],"backgroundTag":"platform-rate-limit-exceeded","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}