gitroomhq/postiz-app · error · Error

Integration not allowed

Error message

Integration not allowed

What it means

POST /integration/:id/additional-settings expects the additionalSettings body field to be a string (providers store settings as a serialized string). If the client sends an object, array, number, or omits the field, the typeof check fails and Error('Invalid body') is thrown (500 to the client).

Source

Thrown at apps/backend/src/api/routes/enterprise.controller.ts:71

        webhookUrl: string;
      };

      if (!load || !load.redirectUrl || !load.apiKey || !load.provider) {
        return;
      }

      const org = await this._organizationService.getOrgByApiKey(load.apiKey);

      if (!org) {
        throw new Error('Organization not found');
      }

      if (
        !this._integrationManager
          .getAllowedSocialsIntegrations()
          .includes(load.provider)
      ) {
        throw new Error('Integration not allowed');
      }

      const integrationProvider = this._integrationManager.getSocialIntegration(
        load.provider
      );

      const { codeVerifier, state, url } =
        await integrationProvider.generateAuthUrl();

      if (load.refreshId) {
        await ioRedis.set(`refresh:${state}`, load.refreshId, 'EX', 3600);
      }

      await ioRedis.set(`webhookUrl:${state}`, load.webhookUrl, 'EX', 3600);
      await ioRedis.set(`redirect:${state}`, load.redirectUrl, 'EX', 3600);
      await ioRedis.set(`organization:${state}`, org.id, 'EX', 3600);
      await ioRedis.set(`login:${state}`, codeVerifier, 'EX', 3600);

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Serialize the settings client-side: send JSON.stringify(settings) as additionalSettings
  2. Ensure the request has Content-Type: application/json and the field is present
  3. Add request validation (class-validator DTO) so this returns 400 with a clear message

Example fix

// before
await fetch(`/integration/${id}/additional-settings`, {
  body: JSON.stringify({ additionalSettings: settings })
});
// after
await fetch(`/integration/${id}/additional-settings`, {
  body: JSON.stringify({ additionalSettings: JSON.stringify(settings) })
});
Defensive patterns

Strategy: validation

Validate before calling

if (typeof additionalSettings !== 'string') {
  payload.additionalSettings = JSON.stringify(additionalSettings);
}

Type guard

const isSettingsString = (v: unknown): v is string => typeof v === 'string';

Try / catch

try { await updateSettings(id, settings); } catch (e) { if (e.message === 'Invalid body') retryWithSerialized(settings); else throw e; }

Prevention

When it happens

Trigger: Sending { additionalSettings: { foo: true } } or any non-string JSON value to the endpoint; sending an empty body.

Common situations: Frontend code JSON.stringifying in one place but not another; client sending a structured object assuming the API parses it; API consumers testing with curl omitting Content-Type leading to undefined body.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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