yikart/AiToEarn · error · BilibiliPlatformException

ChannelPlatformResponseInvalid

ChannelPlatformResponseInvalid

Error message

ResponseCode.ChannelPlatformResponseInvalid

What it means

BilibiliService.submitArchive uploads via /arcopen/fn/archive/add-by-utoken and expects a resource_id in the response. When Bilibili responds without resource_id it throws BilibiliPlatformException ChannelPlatformResponseInvalid, category PlatformUnavailable, cause Platform — the archive submission result is unusable.

Source

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

      desc: params.description ?? '',
      ...(cover ? { cover } : {}),
      ...(params.source ? { source: params.source } : {}),
      ...(params.topicId ? { topic_id: params.topicId } : {}),
      ...(params.missionId ? { mission_id: params.missionId } : {}),
    }

    const data = await this.signedRequest<{
      resource_id?: string
    }>(
      'POST',
      '/arcopen/fn/archive/add-by-utoken',
      accessToken,
      body,
      { upload_token: uploadInfo.uploadToken },
    )

    if (!data.resource_id) {
      throw new BilibiliPlatformException({
        code: ResponseCode.ChannelPlatformResponseInvalid,
        category: PlatformErrorCategory.PlatformUnavailable,
        context: { endpoint: 'POST /arcopen/fn/archive/add-by-utoken' },
        cause: { type: PlatformErrorCauseType.Platform },
      })
    }

    return {
      resourceId: data.resource_id,
    }
  }

  async uploadCover(
    accessToken: string,
    coverUrl: string,
  ): Promise<string> {
    const coverBuffer = await this.mediaService.getBuffer({
      platform: AccountType.Bilibili,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Log the full Bilibili response body to see any embedded error code/message explaining the missing resource_id.
  2. Verify the upload token is fresh and matches the uploaded file, and that the chosen tid is valid for the account.
  3. Retry after confirming upload completion (wait for the upload/transcode step to finish) before add-by-utoken.
  4. Check Bilibili open-platform API docs/changelog for response schema changes and update the parsing type.

Example fix

// before
const data = await submit(accessToken, body, { upload_token: staleToken })

// after
const token = await getFreshUploadToken(accessToken)
await waitForUploadComplete(taskId)
const data = await submit(accessToken, body, { upload_token: token })
if (!data.resource_id) throw new ResponseInvalid(data)
Defensive patterns

Strategy: retry

Validate before calling

const token = await getFreshUploadToken(accessToken) // never reuse upload tokens
await waitForUploadComplete(taskId) // ensure upload finished before add-by-utoken

Type guard

function hasResourceId(d: unknown): d is { resource_id: string } {
  return typeof d === 'object' && d !== null && typeof (d as any).resource_id === 'string' && (d as any).resource_id.length > 0
}

Try / catch

try {
  result = await bilibiliService.submitArchive(accessToken, body, uploadToken)
} catch (e) {
  if (e.code === 'ChannelPlatformResponseInvalid') {
    logger.error('archive add-by-utoken returned no resource_id', e.context)
    // retry once with a fresh upload token, else surface platform-unavailable
  } else throw e
}

Prevention

When it happens

Trigger: Archive submission call completes HTTP-wise but the payload lacks data.resource_id — e.g. Bilibili accepted the request shape but rejected/queued the archive, returned an error envelope inside data, or an API contract change removed/renamed the field.

Common situations: Video still processing on Bilibili's side when add-by-utoken is called; upload token (upload_token) expired or bound to another session; Bilibili open-platform API version changed response schema; insufficient account permissions for the archive type (tid).

Related errors


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