{"record":{"id":"0025013ea221fde4","repo":"gitroomhq/postiz-app","slug":"failed-to-create-linkdrip-api-short-link-with-stat","errorCode":null,"errorMessage":"Failed to create LinkDrip API short link with status: ${response.status}","messagePattern":"Failed to create LinkDrip API short link with status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts","lineNumber":34,"sourceCode":"  shortLinkDomain = LINK_DRIP_SHORT_LINK_DOMAIN;\n\n  async linksStatistics(links: string[]) {\n    return Promise.resolve([]);\n  }\n\n  async convertLinkToShortLink(id: string, link: string) {\n    try {\n      const response = await fetch(`${LINK_DRIP_API_ENDPOINT}/create`, {\n        ...getOptions(),\n        method: 'POST',\n        body: JSON.stringify({\n          target_url: link,\n          custom_domain: this.shortLinkDomain,\n        }),\n      });\n\n      if (!response.ok) {\n        throw new Error(\n          `Failed to create LinkDrip API short link with status: ${response.status}`\n        );\n      }\n\n      const data = await response.json();\n      return data.link;\n    } catch (error) {\n      throw new Error(`Failed to create LinkDrip short link: ${error}`);\n    }\n  }\n\n  async convertShortLinkToLink(shortLink: string) {\n    return '';\n  }\n\n  getAllLinksStatistics(\n    id: string,\n    page: number","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts#L16-L52","documentation":"Thrown by the LinkDrip short-link provider when POST to the LinkDrip API to create a short link returns a non-ok status. The status code is embedded in the message. Common statuses: 401 bad/missing API key, 400 invalid target_url or custom_domain, 403 domain not permitted.","triggerScenarios":"Calling convertLinkToShortLink(link) with a missing/expired LINKDRIP_API_KEY (or equivalent env), a custom_domain (shortLinkDomain) not registered in LinkDrip, or a malformed target_url in the JSON body.","commonSituations":"API key rotated in LinkDrip dashboard but not updated in env; the configured short-link domain expired or was removed from the LinkDrip account; provider env vars not set in a new deployment environment.","solutions":["Reproduce with curl against the LinkDrip create-link endpoint with the same payload and key to see the exact status/body","Verify the API key env var is set and valid for the account","Confirm the custom_domain in the payload is an approved domain in LinkDrip","Validate target_url is an absolute https URL before calling"],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(\n    `Failed to create LinkDrip API short link with status: ${response.status}`\n  );\n}\n\n// after\nif (!response.ok) {\n  const body = await response.text();\n  throw new Error(\n    `Failed to create LinkDrip API short link with status: ${response.status}: ${body}`\n  );\n}","handlingStrategy":"try-catch","validationCode":"if (!process.env.LINKDRIP_API_KEY) {\n  // skip shortening\n}\nconst ok = (() => { try { const u = new URL(link); return u.protocol === 'https:'; } catch { return false; } })();","typeGuard":"function isLinkDripStatusError(e: unknown): e is Error {\n  return e instanceof Error && /LinkDrip API short link with status: \\d+/.test(e.message);\n}","tryCatchPattern":"try {\n  short = await linkdrip.convertLinkToShortLink(url);\n} catch (e) {\n  const m = /status: (\\d+)/.exec(String(e));\n  if (m && ['401','403'].includes(m[1])) throw e; // auth/config: fix env\n  short = url;\n}","preventionTips":["Keep the LinkDrip API key and approved domain in sync via env vars","Run a smoke-test shortening call at deploy time to catch auth/config drift early"],"tags":["linkdrip","http","short-link","api-key","create"],"backgroundTag":"http-error-status","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}