{"record":{"id":"d1df8c6588fdfdb0","repo":"yikart/AiToEarn","slug":"channelpublishplatformworkidmissing","errorCode":"ChannelPublishPlatformWorkIdMissing","errorMessage":"ChannelPublishPlatformWorkIdMissing","messagePattern":"ChannelPublishPlatformWorkIdMissing","errorType":"error_code","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat-channels/wechat-channels-publish.provider.ts","lineNumber":50,"sourceCode":"        }],\n      }\n    }\n\n    return { valid: true }\n  }\n\n  async normalize(input: PublishNormalizeInput<WeChatChannelsOption>): Promise<NormalizedPublishTask<WeChatChannelsOption>> {\n    return {\n      content: input.content,\n      option: input.option,\n    }\n  }\n\n  async publish(input: PublishPublishInput<WeChatChannelsOption>): Promise<PublishProviderResult<WeChatChannelsDataOption>> {\n    const option = input.option\n    const platformWorkId = option?.workId || option?.workLink\n    if (!platformWorkId) {\n      throw new AppException(ResponseCode.ChannelPublishPlatformWorkIdMissing)\n    }\n\n    return {\n      status: 200,\n      platformWorkId,\n      permalink: option?.workLink,\n      linkStatus: option?.linkStatus === PublishRecordLinkStatus.PENDING\n        ? PublishRecordLinkStatus.PENDING\n        : PublishRecordLinkStatus.READY,\n      linkMeta: option?.linkMeta,\n      dataOption: option?.linkMeta ? { linkMeta: option.linkMeta } : undefined,\n    }\n  }\n}\n","sourceCodeStart":32,"sourceCodeEnd":65,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat-channels/wechat-channels-publish.provider.ts#L32-L65","documentation":"The WeChat Channels publish provider requires the publish option to carry either a workId or a workLink identifying the video/post to publish on the platform. When both are absent, AppException(ResponseCode.ChannelPublishPlatformWorkIdMissing) is thrown before any platform call is made.","triggerScenarios":"Calling publish with option undefined, or a WeChatChannelsOption containing neither workId nor workLink — e.g. the upstream task was created from a scheduled post whose reference was never resolved.","commonSituations":"Importing/republishing a WeChat Channels work where the link extraction failed, manually constructed publish options missing required fields, database records with cleared work references.","solutions":["Ensure publish input.option includes workId or workLink before invoking the provider","Validate the scheduling/publish payload at task creation so work references are mandatory","Re-import or re-link the WeChat Channels work to regenerate its workId/workLink","Fix data backfills where workId/workLink were wiped"],"exampleFix":"// before\nawait provider.publish({ option: {} })\n// after\nif (!option?.workId && !option?.workLink) {\n  throw new Error('WeChat Channels publish requires workId or workLink')\n}\nawait provider.publish({ option })","handlingStrategy":"validation","validationCode":"function ensureWechatChannelsWorkRef(option?: { workId?: string; workLink?: string }) {\n  if (!option?.workId && !option?.workLink) {\n    throw new Error('WeChat Channels publish requires option.workId or option.workLink')\n  }\n}\n// call before provider.publish(input)","typeGuard":"function hasWorkRef(o: unknown): o is { workId?: string; workLink?: string } & ({ workId: string } | { workLink: string }) {\n  const o2 = o as any\n  return typeof o2?.workId === 'string' || typeof o2?.workLink === 'string'\n}","tryCatchPattern":"try {\n  await provider.publish(input)\n} catch (e) {\n  if (e?.code === 'ChannelPublishPlatformWorkIdMissing') {\n    logger.error('publish task missing workId/workLink', { taskId })\n    await markTaskFailed(taskId, 'missing work reference')\n  } else throw e\n}","preventionTips":["Make workId/workLink mandatory at task creation","Validate publish payloads at the API boundary","Backfill missing work references in DB records","Re-import works whose link extraction failed"],"tags":["wechat-channels","validation","missing-parameter","publish"],"backgroundTag":"missing-required-parameter","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}