gitroomhq/postiz-app · error · Error

Failed to create LinkDrip short link: ${error}

Error message

Failed to create LinkDrip short link: ${error}

What it means

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>'.

Source

Thrown at libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts:42

      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: number
  ): Promise<{ short: string; original: string; clicks: string }[]> {
    return Promise.resolve([]);
  }
}

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Read the suffix after 'Failed to create LinkDrip short link:' to identify the root cause and fix accordingly
  2. Check network egress to the LinkDrip API host if the suffix is a fetch error
  3. Add retry with backoff for transient failures and fall back to the original long URL
  4. Preserve the cause with { cause: error } instead of string interpolation

Example fix

// before
} catch (error) {
  throw new Error(`Failed to create LinkDrip short link: ${error}`);
}

// after
} catch (error) {
  throw new Error(
    `Failed to create LinkDrip short link: ${error instanceof Error ? error.message : error}`,
    { cause: error }
  );
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!process.env.LINKDRIP_API_KEY || !process.env.LINKDRIP_API_ENDPOINT) {
  return link; // provider not configured: use original URL
}

Type guard

function isLinkDripFailure(e: unknown): e is Error {
  return e instanceof Error && e.message.startsWith('Failed to create LinkDrip short link:');
}

Try / catch

try {
  return await linkdrip.convertLinkToShortLink(link);
} catch (error) {
  if (/status: 40[13]/.test(String(error))) throw error;
  return link;
}

Prevention

When it happens

Trigger: 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).

Common situations: Transient LinkDrip API outages; env vars missing in CI; corporate proxies blocking the outbound request; API base URL changed by the provider.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/06a3861154928104. Report an issue: GitHub.