yikart/AiToEarn · error · AppException
InvalidWorkLink
InvalidWorkLink
Error message
InvalidWorkLink
What it means
getLinkInfo could not obtain both an Instagram shortcode from the link and a dataId. parseInstagramShortCode returned null/empty or input.dataId was missing, so the link isn't a usable Instagram work reference.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-work.provider.ts:63
likeCount: media.like_count,
commentCount: media.comments_count,
},
})),
pagination: {
mode: ChannelPaginationMode.Cursor,
nextCursor: response.paging?.cursors?.after,
previousCursor: response.paging?.cursors?.before,
hasNext: Boolean(response.paging?.next),
hasPrevious: Boolean(response.paging?.previous),
limit,
},
}
}
async getLinkInfo(input: WorkLinkInfoInput): Promise<ChannelWorkDataResult> {
const shortcode = this.parseInstagramShortCode(input.link)
if (!shortcode || !input.dataId) {
throw new AppException(ResponseCode.InvalidWorkLink)
}
return {
snapshots: [],
work: {
id: input.dataId,
url: input.link,
},
extra: {
shortcode,
dataId: input.dataId,
resolvedUrl: input.link,
},
}
}
async getDetail(input: WorkDetailInput): Promise<ChannelWorkDataResult> {
const media = await this.instagramService.getMediaInfo(
input.credential.accessToken,View on GitHub (pinned to d3aa8bea5b)
Solutions
- Verify input.dataId is populated for the work being refreshed
- Ensure the pasted link is a canonical instagram.com/p/<shortcode>/ or /reel/<shortcode>/ URL
- Extend parseInstagramShortCode to accept the URL format users are pasting
- Log input.link and parsed result to diagnose which of the two checks failed
Defensive patterns
Strategy: validation
Validate before calling
const IG_RE = /instagram\.com\/(?:p|reel|reels|tv)\/([A-Za-z0-9_-]+)/
const match = input.link?.match(IG_RE)
if (!match || !input.dataId) {
throw new Error('Need an instagram.com/p|reel/<shortcode> URL and a dataId')
} Type guard
function isInstagramWorkInput(i: { link?: string; dataId?: string }): i is { link: string; dataId: string } {
return typeof i.link === 'string' && /instagram\.com\/(p|reel|tv)\/[A-Za-z0-9_-]+/.test(i.link) && typeof i.dataId === 'string' && i.dataId.length > 0
} Prevention
- Ensure dataId is captured when the work record is first created
- Accept only canonical /p/, /reel/, /tv/ permalinks in the input UI
- Update the shortcode parser when Instagram ships new share URL formats
- Log both parsed shortcode and dataId to identify which check failed
When it happens
Trigger: Calling getLinkInfo with input.link that doesn't match an Instagram post/reel URL (no /p/<code>/ or /reel/<code>/ segment), or with a valid link but input.dataId undefined.
Common situations: Users paste profile or story URLs; the shortcode regex misses new formats (e.g. /share/reel/ links); caller forgot to supply dataId when the work record was created.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/974aac91b9d4a4de.
Report an issue: GitHub.