gitroomhq/postiz-app · error · BadRequestException

Integration with id ${post.integration.id} not found

Error message

Integration with id ${post.integration.id} not found

What it means

During createPost mapping, each post's integration.id is resolved via IntegrationService.getIntegrationById scoped to the organization. If no integration with that id exists (or belongs to another org), a BadRequestException names the offending id.

Source

Thrown at libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts:268

    organization: string,
    replaceDraft: boolean = false
  ): Promise<CreatePostDto> {
    if (!body?.posts?.every((p) => p?.integration?.id)) {
      throw new BadRequestException('All posts must have an integration id');
    }

    const mappedValues = {
      ...body,
      type: replaceDraft ? 'schedule' : body?.type,
      posts: await Promise.all(
        body?.posts?.map(async (post) => {
          const integration = await this._integrationService.getIntegrationById(
            organization,
            post.integration.id
          );

          if (!integration) {
            throw new BadRequestException(
              `Integration with id ${post.integration.id} not found`
            );
          }

          return {
            type: replaceDraft ? 'schedule' : body?.type,
            ...post,
            settings: {
              ...(post.settings || ({} as any)),
              __type: integration.providerIdentifier,
            },
          };
        }) || []
      ),
    };

    const validationPipe = new ValidationPipe({
      skipMissingProperties: false,

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Re-fetch the organization's integrations (GET integrations list) and use a current id
  2. Reconnect the social channel if the integration was removed, then resubmit with the new id
  3. Verify the orgId in the URL matches the organization that owns the integration
  4. Add client-side validation that the selected integration id exists in the loaded integrations list

Example fix

// before
const integrationId = cachedDraft.integration.id; // stale
await createPost(orgId, { posts: [{ integration: { id: integrationId }, content }] });
// after
const { integrations } = await fetchIntegrations(orgId);
const integration = integrations.find(i => i.id === wantedId);
if (!integration) throw new Error('Reconnect the channel');
await createPost(orgId, { posts: [{ integration: { id: integration.id }, content }] });
Defensive patterns

Strategy: validation

Validate before calling

const { integrations } = await fetchIntegrations(orgId);
const ids = new Set(integrations.map((i) => i.id));
const valid = body.posts.every((p) => ids.has(p.integration.id));
if (valid) await createPost(orgId, body);

Try / catch

try {
  await createPost(orgId, body);
} catch (e) {
  if (e?.response?.status === 400 && /Integration with id .* not found/.test(e.response.message)) {
    await refreshIntegrations(); // reselect channel, resubmit
  } else throw e;
}

Prevention

When it happens

Trigger: POST /organization/:orgId/posts with an integration id that was deleted, belongs to a different organization, or is a malformed/garbled string (e.g. stale id from another workspace).

Common situations: Client caches old integration ids after a channel was disconnected/reconnected; copying payloads between environments (dev/staging); typos in hand-built API requests; org context mismatch in the URL vs integration ownership.

Related errors


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