yikart/AiToEarn · error · AppException

ChannelPublishPlatformWorkIdMissing

ChannelPublishPlatformWorkIdMissing

Error message

ChannelPublishPlatformWorkIdMissing

What it means

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.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat-channels/wechat-channels-publish.provider.ts:50

        }],
      }
    }

    return { valid: true }
  }

  async normalize(input: PublishNormalizeInput<WeChatChannelsOption>): Promise<NormalizedPublishTask<WeChatChannelsOption>> {
    return {
      content: input.content,
      option: input.option,
    }
  }

  async publish(input: PublishPublishInput<WeChatChannelsOption>): Promise<PublishProviderResult<WeChatChannelsDataOption>> {
    const option = input.option
    const platformWorkId = option?.workId || option?.workLink
    if (!platformWorkId) {
      throw new AppException(ResponseCode.ChannelPublishPlatformWorkIdMissing)
    }

    return {
      status: 200,
      platformWorkId,
      permalink: option?.workLink,
      linkStatus: option?.linkStatus === PublishRecordLinkStatus.PENDING
        ? PublishRecordLinkStatus.PENDING
        : PublishRecordLinkStatus.READY,
      linkMeta: option?.linkMeta,
      dataOption: option?.linkMeta ? { linkMeta: option.linkMeta } : undefined,
    }
  }
}

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Ensure publish input.option includes workId or workLink before invoking the provider
  2. Validate the scheduling/publish payload at task creation so work references are mandatory
  3. Re-import or re-link the WeChat Channels work to regenerate its workId/workLink
  4. Fix data backfills where workId/workLink were wiped

Example fix

// before
await provider.publish({ option: {} })
// after
if (!option?.workId && !option?.workLink) {
  throw new Error('WeChat Channels publish requires workId or workLink')
}
await provider.publish({ option })
Defensive patterns

Strategy: validation

Validate before calling

function ensureWechatChannelsWorkRef(option?: { workId?: string; workLink?: string }) {
  if (!option?.workId && !option?.workLink) {
    throw new Error('WeChat Channels publish requires option.workId or option.workLink')
  }
}
// call before provider.publish(input)

Type guard

function hasWorkRef(o: unknown): o is { workId?: string; workLink?: string } & ({ workId: string } | { workLink: string }) {
  const o2 = o as any
  return typeof o2?.workId === 'string' || typeof o2?.workLink === 'string'
}

Try / catch

try {
  await provider.publish(input)
} catch (e) {
  if (e?.code === 'ChannelPublishPlatformWorkIdMissing') {
    logger.error('publish task missing workId/workLink', { taskId })
    await markTaskFailed(taskId, 'missing work reference')
  } else throw e
}

Prevention

When it happens

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

Common situations: Importing/republishing a WeChat Channels work where the link extraction failed, manually constructed publish options missing required fields, database records with cleared work references.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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