gitroomhq/postiz-app · error · Error

Invalid provider

Error message

Invalid provider

What it means

The final guard in functionIntegration: the provider implementation exists but the dynamic method requested via body.name is not present on it (integrationProvider[body.name] is falsy), so Error('Invalid provider') is thrown. The dispatcher refuses to call methods the provider does not implement.

Source

Thrown at apps/backend/src/api/routes/integrations.controller.ts:349

  @Post('/function')
  async functionIntegration(
    @GetOrgFromRequest() org: Organization,
    @Body() body: IntegrationFunctionDto
  ): Promise<any> {
    const getIntegration = await this._integrationService.getIntegrationById(
      org.id,
      body.id
    );
    if (!getIntegration) {
      throw new Error('Invalid integration');
    }

    const integrationProvider = this._integrationManager.getSocialIntegration(
      getIntegration.providerIdentifier
    );
    if (!integrationProvider) {
      throw new Error('Invalid provider');
    }

    // @ts-ignore
    if (integrationProvider[body.name]) {
      try {
        // @ts-ignore
        const load = await integrationProvider[body.name](
          getIntegration.token,
          body.data,
          getIntegration.internalId,
          getIntegration
        );

        return load;
      } catch (err) {
        // The platform will keep rejecting this channel until the user
        // re-connects it: mark it as needing a refresh instead of retrying.
        if (err instanceof Disconnect) {

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Verify the method name string matches the provider's implementation exactly (case-sensitive)
  2. Feature-detect before calling: only invoke methods the provider is known to expose
  3. If building a custom provider, implement the method or have the client skip it

Example fix

// before
await api.functionIntegration({ id, name: 'getMentions' });
// after
const supported = await api.getProviderCapabilities(id); // includes 'getMentions'?
if (supported.includes('getMentions')) {
  await api.functionIntegration({ id, name: 'getMentions' });
}
Defensive patterns

Strategy: type-guard

Validate before calling

const capabilities = await getProviderCapabilities(integration.id);
if (!capabilities.includes(methodName)) { skipFeature(methodName); }

Type guard

const supportsMethod = (p: Provider, m: string) => typeof (p as any)[m] === 'function';

Try / catch

try { await functionIntegration({ id, name }); } catch (e) { if (e.message === 'Invalid provider') hideFeature(name); else throw e; }

Prevention

When it happens

Trigger: Calling the generic integration-function endpoint with name='getMentions' (or any method) for a provider whose class does not define that method, or with a misspelled method name.

Common situations: Frontend assuming all providers implement an optional capability like mentions or analytics; method renamed across versions while old clients still call the previous name; probing the endpoint manually.

Related errors


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