{"record":{"id":"72c30a01c43c17b2","repo":"yikart/AiToEarn","slug":"platformnotsupported-72c30a","errorCode":"PlatformNotSupported","errorMessage":"PlatformNotSupported","messagePattern":"PlatformNotSupported","errorType":"error_code","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platforms.registry.ts","lineNumber":61,"sourceCode":"    }\n    if (status === PlatformStatus.Available && !this.hasCapabilityProvider(integration)) {\n      throw new Error(`Available platform must register at least one capability provider: ${integration.platform}`)\n    }\n    if (this.platforms.has(integration.platform)) {\n      throw new Error(`Platform already registered: ${integration.platform}`)\n    }\n    this.platforms.set(integration.platform, {\n      integration,\n      metadata: this.createMetadataCache(integration),\n    })\n    this.logger.log({ platform: integration.platform }, 'Registered platform')\n  }\n\n  get(platform: AccountType): PlatformIntegration {\n    const registeredPlatform = this.platforms.get(platform)\n    if (!registeredPlatform) {\n      this.logger.warn({ platform }, 'Platform not registered')\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform })\n    }\n    return registeredPlatform.integration\n  }\n\n  getAuth(platform: AccountType): AuthProvider {\n    const integration = this.get(platform)\n    if (!integration.auth) {\n      this.logger.warn({ platform }, 'Platform does not support auth')\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform, capability: 'auth' })\n    }\n    return integration.auth\n  }\n\n  getPublish(platform: AccountType): PublishProvider {\n    const integration = this.get(platform)\n    if (!integration.publish) {\n      this.logger.warn({ platform }, 'Platform does not support publish')\n      throw new AppException(ResponseCode.ChannelPublishPlatformNotSupported, { platform })","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platforms.registry.ts#L43-L79","documentation":"PlatformIntegrationRegistry.get looks up the platform integration Map keyed by AccountType. If the platform was never registered (no module called register() for that AccountType at startup), it logs a warning and throws PlatformNotSupported with the offending platform value. Every capability accessor (getAuth, getPublish, getWebhook, ...) routes through get, so an unregistered platform fails at the first lookup.","triggerScenarios":"Any API call whose account.type / :platform parameter is an AccountType value for which no integration module registered an integration in the registry — e.g. a stored account whose platform enum value has no corresponding integration module loaded, or a request passing an arbitrary platform string to a platform-scoped endpoint.","commonSituations":"A new AccountType added to the enum but the integration module not yet imported into the channels module; feature flag / status Hidden preventing registration while old accounts still reference the platform; env-specific module loading (a platform module excluded in this deployment); typos in platform strings from clients.","solutions":["Check registry.has(platform) or the platform capabilities/metadata listing before calling, and surface a friendly 'platform not available' message to the user.","Verify the platform's integration module is registered in this deployment (check the channels module imports / registration for that AccountType).","Confirm the account's type value is valid and not from a disabled/Hidden platform; migrate or deactivate such accounts.","Validate user-supplied platform parameters against the enum/registered list at the controller boundary (Zod schema)."],"exampleFix":"// before\nconst publish = registry.getPublish(account.type as AccountType)\n// after\nif (!registry.has(account.type)) {\n  throw new BadRequestException(`Platform ${account.type} is not available`)\n}\nconst publish = registry.getPublish(account.type)","handlingStrategy":"validation","validationCode":"const platformSchema = z.enum(registeredPlatforms) // from registry.listMetadata() / AccountType list\nplatformSchema.parse(userSuppliedPlatform)","typeGuard":"function isRegisteredPlatform(platform: AccountType): boolean {\n  return registry.has(platform)\n}","tryCatchPattern":"try {\n  return await channelApi.call(platform, payload)\n} catch (e) {\n  if (e instanceof AppException && e.code === ResponseCode.PlatformNotSupported) {\n    throw new BadRequestException(`Platform ${e.details.platform} is not available on this deployment`)\n  }\n  throw e\n}","preventionTips":["Validate user-supplied platform values against the registered platform list at the API boundary.","Ensure every AccountType that can appear in stored accounts has a registered integration in each deployment.","Watch the 'Platform not registered' warning logs — they indicate enum/registration drift.","Handle Hidden/disabled platforms by migrating or deactivating their accounts."],"tags":["platform-registry","configuration","unsupported-platform"],"backgroundTag":"platform-not-supported","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}