yikart/AiToEarn · warning · AppException

InvalidWorkLink

InvalidWorkLink

Error message

InvalidWorkLink

What it means

InvalidWorkLink is thrown by PinterestWorkProvider.getLinkInfo when the link cannot be parsed into a Pinterest pin ID. After normalizing the URL (resolving redirects), parsePinterestPinId returns null, meaning the URL does not match a Pinterest pin URL pattern.

Source

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

        url: buildPinterestPinWorkLink(pin.id),
        coverUrl: pin.media?.images?.['1200x']?.url,
        publishedAt: parsePlatformDate(pin.created_at),
      })),
      pagination: {
        mode: ChannelPaginationMode.Cursor,
        nextCursor: response.bookmark,
        hasNext: Boolean(response.bookmark),
        hasPrevious: false,
        limit,
      },
    }
  }

  async getLinkInfo(input: WorkLinkInfoInput): Promise<ChannelWorkDataResult> {
    const resolvedUrl = await this.normalizeLink(input.link)
    const pinId = this.parsePinterestPinId(resolvedUrl)
    if (!pinId) {
      throw new AppException(ResponseCode.InvalidWorkLink)
    }
    const url = buildPinterestPinWorkLink(pinId)
    return {
      snapshots: [],
      work: {
        id: pinId,
        url,
      },
      extra: {
        dataId: pinId,
        uniqueId: `${input.platform}_${pinId}`,
        resolvedUrl,
      },
      rawResponse: { resolvedUrl },
    }
  }

  async getDetail(input: WorkDetailInput): Promise<ChannelWorkDataResult> {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Ensure the link is a pin URL matching the pin-id pattern (e.g. https://www.pinterest.com/pin/<id>/ or pin.it short link that resolves to one)
  2. Open the link in a browser and copy the canonical pin URL
  3. Check that pin.it short links resolve successfully (see error 207 for redirect failures)

Example fix

// before
await provider.getLinkInfo({ link: 'https://www.pinterest.com/myprofile/' }) // no pin id -> InvalidWorkLink
// after
await provider.getLinkInfo({ link: 'https://www.pinterest.com/pin/123456789012345678/' })
Defensive patterns

Strategy: validation

Validate before calling

const PIN_RE = /^https?:\/\/([a-z]+\.)?pinterest\.com\/pin\/(\d+)/i
function isPinterestPinUrl(link: string): boolean { return PIN_RE.test(link.trim()) }
if (!isPinterestPinUrl(link) && !/^https?:\/\/pin\.it\//i.test(link)) throw new Error('Provide a Pinterest pin URL')

Type guard

function extractPinId(url: string): string | null {
  const m = url.match(/pinterest\.com\/pin\/(\d+)/i)
  return m ? m[1] : null
}

Try / catch

try {
  const info = await provider.getLinkInfo({ link })
} catch (e) {
  if (e instanceof AppException && e.code === ResponseCode.InvalidWorkLink) {
    // show 'This does not look like a Pinterest pin link'
  } else throw e
}

Prevention

When it happens

Trigger: Calling getLinkInfo({ link }) with a URL that is not a Pinterest pin link (wrong domain, a profile/board URL, or a short link whose redirect target still contains no pin id).

Common situations: Users paste pinterest.com profile or board URLs instead of a pin URL; links from other platforms pasted into a Pinterest channel; localized/redirected URLs with unexpected formats.

Related errors


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