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
- Verify the link is a Kwai photo/short-video URL containing an id (e.g. /short-video/<id> or photoId param)
- Ask the user to use the in-app share 'copy link' output
- Extend parsePhotoId to support the URL variant being pasted
- 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
- Only accept Kwai share links that include a photo/short-video id in the input UI
- Normalize short links before showing acceptance errors
- Keep parsePhotoId updated with new Kwai share formats
- Show users an example of a valid Kwai work link
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.