yikart/AiToEarn · error · AppException

ChannelPlatformOperationNotSupported

ChannelPlatformOperationNotSupported

Error message

ChannelPlatformOperationNotSupported

What it means

createAccountValue handles dynamic 'publish option' fields (custom create-value sources, e.g. creating a board/list on the platform). After resolving { account, provider, source } via getAccountOptionContext, if the resolved provider has no createValue implementation or the source has no createSchema, the field is list-only and cannot have values created, so it throws ChannelPlatformOperationNotSupported with the platform and field.

Source

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

      filters: parsedFilters,
      credential: {
        accessToken: credential.accessToken,
        refreshToken: credential.refreshToken,
        platformUid: account.uid,
        account: account.account,
      },
    }))
  }

  async createAccountValue(
    userId: string,
    accountId: string,
    field: string,
    data?: object,
  ): Promise<PublishOptionCreateResult> {
    const { account, provider, source } = await this.getAccountOptionContext(userId, accountId, field)
    if (!provider.createValue || !source.createSchema) {
      throw new AppException(ResponseCode.ChannelPlatformOperationNotSupported, {
        platform: account.type,
        field,
      })
    }

    const parsedData = source.createSchema.parse(data ?? {}) as Record<string, unknown>
    const credential = await this.authService.getValidCredential(accountId, userId)
    return this.callAccountProvider(accountId, () => provider.createValue!({
      userId,
      accountId,
      field,
      data: parsedData,
      credential: {
        accessToken: credential.accessToken,
        refreshToken: credential.refreshToken,
        platformUid: account.uid,
        account: account.account,
      },

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Consult the field's option source metadata (whether create is offered, e.g. via optionSchema / source capabilities) and hide the create action for list-only fields.
  2. Use the list endpoint (values from listSources/list values) instead of the create endpoint for fields without create support.
  3. If creation should be supported, implement provider.createValue and define source.createSchema in the platform integration.
  4. Map this response code in the client to a per-field 'operation not available' message rather than a global error.

Example fix

// before
await api.post(`/accounts/${accountId}/options/${field}/values`, data) // may 400
// after
if (!fieldMeta.canCreate) {
  throw new BadRequestException(`Field ${field} does not support creating values`)
}
await api.post(`/accounts/${accountId}/options/${field}/values`, data)
Defensive patterns

Strategy: validation

Validate before calling

const source = optionSources.find(s => s.field === field)
if (!source?.canCreate) { // no createValue / createSchema
  throw new BadRequestException(`Field ${field} is read-only`)
}

Type guard

function isCreatableSource(source: PublishOptionSource): source is PublishOptionSource & { createSchema: z.ZodTypeAny } {
  return Boolean(source.createSchema)
}

Try / catch

try {
  await api.createAccountValue(accountId, field, data)
} catch (e) {
  if (e instanceof AppException && e.code === ResponseCode.ChannelPlatformOperationNotSupported) {
    showError(`Cannot create values for ${e.details.field} on ${e.details.platform}`)
    return
  }
  throw e
}

Prevention

When it happens

Trigger: POSTing to the create-account-value endpoint (userId, accountId, field, data) where `field` names an option source that only supports listing (provider.createValue undefined or source.createSchema undefined) — e.g. trying to 'create' a value for a read-only dropdown like a fixed category list.

Common situations: A UI that renders a generic '+ add new' button next to every option field; clients guessing the create endpoint works for all fields; schema changed so createSchema was dropped while the client still calls create.

Related errors


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