yikart/AiToEarn · error · AppException

PlatformNotSupported

PlatformNotSupported

Error message

PlatformNotSupported

What it means

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.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platforms.registry.ts:61

    }
    if (status === PlatformStatus.Available && !this.hasCapabilityProvider(integration)) {
      throw new Error(`Available platform must register at least one capability provider: ${integration.platform}`)
    }
    if (this.platforms.has(integration.platform)) {
      throw new Error(`Platform already registered: ${integration.platform}`)
    }
    this.platforms.set(integration.platform, {
      integration,
      metadata: this.createMetadataCache(integration),
    })
    this.logger.log({ platform: integration.platform }, 'Registered platform')
  }

  get(platform: AccountType): PlatformIntegration {
    const registeredPlatform = this.platforms.get(platform)
    if (!registeredPlatform) {
      this.logger.warn({ platform }, 'Platform not registered')
      throw new AppException(ResponseCode.PlatformNotSupported, { platform })
    }
    return registeredPlatform.integration
  }

  getAuth(platform: AccountType): AuthProvider {
    const integration = this.get(platform)
    if (!integration.auth) {
      this.logger.warn({ platform }, 'Platform does not support auth')
      throw new AppException(ResponseCode.PlatformNotSupported, { platform, capability: 'auth' })
    }
    return integration.auth
  }

  getPublish(platform: AccountType): PublishProvider {
    const integration = this.get(platform)
    if (!integration.publish) {
      this.logger.warn({ platform }, 'Platform does not support publish')
      throw new AppException(ResponseCode.ChannelPublishPlatformNotSupported, { platform })

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Check registry.has(platform) or the platform capabilities/metadata listing before calling, and surface a friendly 'platform not available' message to the user.
  2. Verify the platform's integration module is registered in this deployment (check the channels module imports / registration for that AccountType).
  3. Confirm the account's type value is valid and not from a disabled/Hidden platform; migrate or deactivate such accounts.
  4. Validate user-supplied platform parameters against the enum/registered list at the controller boundary (Zod schema).

Example fix

// before
const publish = registry.getPublish(account.type as AccountType)
// after
if (!registry.has(account.type)) {
  throw new BadRequestException(`Platform ${account.type} is not available`)
}
const publish = registry.getPublish(account.type)
Defensive patterns

Strategy: validation

Validate before calling

const platformSchema = z.enum(registeredPlatforms) // from registry.listMetadata() / AccountType list
platformSchema.parse(userSuppliedPlatform)

Type guard

function isRegisteredPlatform(platform: AccountType): boolean {
  return registry.has(platform)
}

Try / catch

try {
  return await channelApi.call(platform, payload)
} catch (e) {
  if (e instanceof AppException && e.code === ResponseCode.PlatformNotSupported) {
    throw new BadRequestException(`Platform ${e.details.platform} is not available on this deployment`)
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/72c30a01c43c17b2. Report an issue: GitHub.