{"record":{"id":"06a3861154928104","repo":"gitroomhq/postiz-app","slug":"failed-to-create-linkdrip-short-link-error","errorCode":null,"errorMessage":"Failed to create LinkDrip short link: ${error}","messagePattern":"Failed to create LinkDrip short link: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts","lineNumber":42,"sourceCode":"      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\n  ): Promise<{ short: string; original: string; clicks: string }[]> {\n    return Promise.resolve([]);\n  }\n}\n","sourceCodeStart":24,"sourceCodeEnd":57,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts#L24-L57","documentation":"Catch-all wrapper thrown by LinkDrip's convertLinkToShortLink when anything in the try block fails: the inner HTTP status error, a network failure reaching the LinkDrip API, or a non-JSON response body. The original error is stringified into 'Failed to create LinkDrip short link: <cause>'.","triggerScenarios":"The wrapped cause appears after the colon: 'status: 401/403/429' for auth/ratelimit, 'fetch failed' for DNS/network problems, or a JSON parse error when the API returns HTML (e.g. a gateway error page).","commonSituations":"Transient LinkDrip API outages; env vars missing in CI; corporate proxies blocking the outbound request; API base URL changed by the provider.","solutions":["Read the suffix after 'Failed to create LinkDrip short link:' to identify the root cause and fix accordingly","Check network egress to the LinkDrip API host if the suffix is a fetch error","Add retry with backoff for transient failures and fall back to the original long URL","Preserve the cause with { cause: error } instead of string interpolation"],"exampleFix":"// before\n} catch (error) {\n  throw new Error(`Failed to create LinkDrip short link: ${error}`);\n}\n\n// after\n} catch (error) {\n  throw new Error(\n    `Failed to create LinkDrip short link: ${error instanceof Error ? error.message : error}`,\n    { cause: error }\n  );\n}","handlingStrategy":"fallback","validationCode":"if (!process.env.LINKDRIP_API_KEY || !process.env.LINKDRIP_API_ENDPOINT) {\n  return link; // provider not configured: use original URL\n}","typeGuard":"function isLinkDripFailure(e: unknown): e is Error {\n  return e instanceof Error && e.message.startsWith('Failed to create LinkDrip short link:');\n}","tryCatchPattern":"try {\n  return await linkdrip.convertLinkToShortLink(link);\n} catch (error) {\n  if (/status: 40[13]/.test(String(error))) throw error;\n  return link;\n}","preventionTips":["Distinguish auth failures (fix immediately) from transient ones (retry/fallback) by inspecting the wrapped message","Add a timeout and circuit breaker around the provider so outages don't cascade"],"tags":["linkdrip","short-link","error-wrapping","network"],"backgroundTag":"short-link-provider-failure","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}