yikart/AiToEarn · error · AppException

InvalidWorkLink

InvalidWorkLink

Error message

InvalidWorkLink

What it means

getLinkInfo could not extract a Kwai photo id from the normalized link. After short-link resolution, parsePhotoId found no match, so the URL isn't a recognized Kwai work/photo link.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/kwai/kwai-work.provider.ts:57

    }, undefined)?.photo_id

    return {
      items: response.items.map(photo => this.toListItem(photo)).filter(item => item.platformWorkId),
      pagination: {
        mode: ChannelPaginationMode.Cursor,
        nextCursor,
        hasNext: response.items.length >= limit,
        hasPrevious: false,
        limit,
      },
    }
  }

  async getLinkInfo(input: WorkLinkInfoInput): Promise<ChannelWorkDataResult> {
    const resolvedUrl = await this.normalizeLink(input.link)
    const photoId = this.parsePhotoId(resolvedUrl)
    if (!photoId) {
      throw new AppException(ResponseCode.InvalidWorkLink)
    }

    const url = this.buildWorkLink(photoId)
    return {
      snapshots: [],
      work: {
        id: photoId,
        url,
        mediaType: PublishType.VIDEO,
      },
      extra: {
        dataId: photoId,
        uniqueId: `${AccountType.Kwai}_${photoId}`,
        type: PublishType.VIDEO,
        videoType: 'short',
        resolvedUrl,
      },
      rawResponse: { resolvedUrl },

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Verify the link is a Kwai photo/short-video URL containing an id (e.g. /short-video/<id> or photoId param)
  2. Ask the user to use the in-app share 'copy link' output
  3. Extend parsePhotoId to support the URL variant being pasted
  4. Log resolvedUrl to see what the parser actually receives
Defensive patterns

Strategy: validation

Validate before calling

const KWAI_RE = /(?:short-video\/(\d+)|photoId=(\d+)|photo\/(\d+))/.source
const resolved = input.link?.match(new RegExp(KWAI_RE))
if (!resolved) {
  throw new Error('Link must be a Kwai photo/short-video URL containing a photo id')
}

Type guard

function isKwaiWorkUrl(url: string): boolean {
  try { const u = new URL(url); return /(^|\.)kwai\.com$|(^|\.)kuaishou\.com$/.test(u.hostname) && /\d{6,}/.test(u.pathname + u.search) } catch { return false }
}

Prevention

When it happens

Trigger: Calling getLinkInfo with input.link that, after normalizeLink, has no photo id pattern (e.g. a user profile link, live link, or unsupported short-link variant).

Common situations: Users paste kwai.com profile or /u/ links, app-share links with new formats, or links from other apps; the id regex doesn't cover the newest share URL shape.

Related errors


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