{"record":{"id":"85ba8b4afeb609a6","repo":"yikart/AiToEarn","slug":"channelplatformresponseinvalid","errorCode":"ChannelPlatformResponseInvalid","errorMessage":"ResponseCode.ChannelPlatformResponseInvalid","messagePattern":"ResponseCode\\.ChannelPlatformResponseInvalid","errorType":"exception","errorClass":"BilibiliPlatformException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/bilibili/bilibili.service.ts","lineNumber":323,"sourceCode":"      desc: params.description ?? '',\n      ...(cover ? { cover } : {}),\n      ...(params.source ? { source: params.source } : {}),\n      ...(params.topicId ? { topic_id: params.topicId } : {}),\n      ...(params.missionId ? { mission_id: params.missionId } : {}),\n    }\n\n    const data = await this.signedRequest<{\n      resource_id?: string\n    }>(\n      'POST',\n      '/arcopen/fn/archive/add-by-utoken',\n      accessToken,\n      body,\n      { upload_token: uploadInfo.uploadToken },\n    )\n\n    if (!data.resource_id) {\n      throw new BilibiliPlatformException({\n        code: ResponseCode.ChannelPlatformResponseInvalid,\n        category: PlatformErrorCategory.PlatformUnavailable,\n        context: { endpoint: 'POST /arcopen/fn/archive/add-by-utoken' },\n        cause: { type: PlatformErrorCauseType.Platform },\n      })\n    }\n\n    return {\n      resourceId: data.resource_id,\n    }\n  }\n\n  async uploadCover(\n    accessToken: string,\n    coverUrl: string,\n  ): Promise<string> {\n    const coverBuffer = await this.mediaService.getBuffer({\n      platform: AccountType.Bilibili,","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/bilibili/bilibili.service.ts#L305-L341","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Log the full Bilibili response body to see any embedded error code/message explaining the missing resource_id.","Verify the upload token is fresh and matches the uploaded file, and that the chosen tid is valid for the account.","Retry after confirming upload completion (wait for the upload/transcode step to finish) before add-by-utoken.","Check Bilibili open-platform API docs/changelog for response schema changes and update the parsing type."],"exampleFix":"// before\nconst data = await submit(accessToken, body, { upload_token: staleToken })\n\n// after\nconst token = await getFreshUploadToken(accessToken)\nawait waitForUploadComplete(taskId)\nconst data = await submit(accessToken, body, { upload_token: token })\nif (!data.resource_id) throw new ResponseInvalid(data)","handlingStrategy":"retry","validationCode":"const token = await getFreshUploadToken(accessToken) // never reuse upload tokens\nawait waitForUploadComplete(taskId) // ensure upload finished before add-by-utoken","typeGuard":"function hasResourceId(d: unknown): d is { resource_id: string } {\n  return typeof d === 'object' && d !== null && typeof (d as any).resource_id === 'string' && (d as any).resource_id.length > 0\n}","tryCatchPattern":"try {\n  result = await bilibiliService.submitArchive(accessToken, body, uploadToken)\n} catch (e) {\n  if (e.code === 'ChannelPlatformResponseInvalid') {\n    logger.error('archive add-by-utoken returned no resource_id', e.context)\n    // retry once with a fresh upload token, else surface platform-unavailable\n  } else throw e\n}","preventionTips":["Use a fresh upload_token per submission and confirm upload completion first","Log the full Bilibili response body to catch embedded error envelopes","Pin/track Bilibili open-platform API versions and watch for schema changes","Validate the chosen tid is permitted for the account before submitting"],"tags":["bilibili","upload","api-response","schema"],"backgroundTag":"unexpected-api-response","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}