gitroomhq/postiz-app · error · Error
Failed to create LinkDrip API short link with status: ${resp
Error message
Failed to create LinkDrip API short link with status: ${response.status} What it means
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.
Source
Thrown at libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts:34
shortLinkDomain = LINK_DRIP_SHORT_LINK_DOMAIN;
async linksStatistics(links: string[]) {
return Promise.resolve([]);
}
async convertLinkToShortLink(id: string, link: string) {
try {
const response = await fetch(`${LINK_DRIP_API_ENDPOINT}/create`, {
...getOptions(),
method: 'POST',
body: JSON.stringify({
target_url: link,
custom_domain: this.shortLinkDomain,
}),
});
if (!response.ok) {
throw new Error(
`Failed to create LinkDrip API short link with status: ${response.status}`
);
}
const data = await response.json();
return data.link;
} catch (error) {
throw new Error(`Failed to create LinkDrip short link: ${error}`);
}
}
async convertShortLinkToLink(shortLink: string) {
return '';
}
getAllLinksStatistics(
id: string,
page: numberView on GitHub (pinned to 0f1647f749)
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
Example fix
// before
if (!response.ok) {
throw new Error(
`Failed to create LinkDrip API short link with status: ${response.status}`
);
}
// after
if (!response.ok) {
const body = await response.text();
throw new Error(
`Failed to create LinkDrip API short link with status: ${response.status}: ${body}`
);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!process.env.LINKDRIP_API_KEY) {
// skip shortening
}
const ok = (() => { try { const u = new URL(link); return u.protocol === 'https:'; } catch { return false; } })(); Type guard
function isLinkDripStatusError(e: unknown): e is Error {
return e instanceof Error && /LinkDrip API short link with status: \d+/.test(e.message);
} Try / catch
try {
short = await linkdrip.convertLinkToShortLink(url);
} catch (e) {
const m = /status: (\d+)/.exec(String(e));
if (m && ['401','403'].includes(m[1])) throw e; // auth/config: fix env
short = url;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- HTTP error! status: ${response.status}
- Failed to create LinkDrip short link: ${error}
- Failed to get profile
- Failed to fetch media: ${fileResponse.statusText}
- Failed to upload the media file
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/0025013ea221fde4.
Report an issue: GitHub.