{"record":{"id":"90410c6a7164f267","repo":"gitroomhq/postiz-app","slug":"integration-with-id-post-integration-id-not-fou","errorCode":null,"errorMessage":"Integration with id ${post.integration.id} not found","messagePattern":"Integration with id (.+?) not found","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts","lineNumber":268,"sourceCode":"    organization: string,\n    replaceDraft: boolean = false\n  ): Promise<CreatePostDto> {\n    if (!body?.posts?.every((p) => p?.integration?.id)) {\n      throw new BadRequestException('All posts must have an integration id');\n    }\n\n    const mappedValues = {\n      ...body,\n      type: replaceDraft ? 'schedule' : body?.type,\n      posts: await Promise.all(\n        body?.posts?.map(async (post) => {\n          const integration = await this._integrationService.getIntegrationById(\n            organization,\n            post.integration.id\n          );\n\n          if (!integration) {\n            throw new BadRequestException(\n              `Integration with id ${post.integration.id} not found`\n            );\n          }\n\n          return {\n            type: replaceDraft ? 'schedule' : body?.type,\n            ...post,\n            settings: {\n              ...(post.settings || ({} as any)),\n              __type: integration.providerIdentifier,\n            },\n          };\n        }) || []\n      ),\n    };\n\n    const validationPipe = new ValidationPipe({\n      skipMissingProperties: false,","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts#L250-L286","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Re-fetch the organization's integrations (GET integrations list) and use a current id","Reconnect the social channel if the integration was removed, then resubmit with the new id","Verify the orgId in the URL matches the organization that owns the integration","Add client-side validation that the selected integration id exists in the loaded integrations list"],"exampleFix":"// before\nconst integrationId = cachedDraft.integration.id; // stale\nawait createPost(orgId, { posts: [{ integration: { id: integrationId }, content }] });\n// after\nconst { integrations } = await fetchIntegrations(orgId);\nconst integration = integrations.find(i => i.id === wantedId);\nif (!integration) throw new Error('Reconnect the channel');\nawait createPost(orgId, { posts: [{ integration: { id: integration.id }, content }] });","handlingStrategy":"validation","validationCode":"const { integrations } = await fetchIntegrations(orgId);\nconst ids = new Set(integrations.map((i) => i.id));\nconst valid = body.posts.every((p) => ids.has(p.integration.id));\nif (valid) await createPost(orgId, body);","typeGuard":null,"tryCatchPattern":"try {\n  await createPost(orgId, body);\n} catch (e) {\n  if (e?.response?.status === 400 && /Integration with id .* not found/.test(e.response.message)) {\n    await refreshIntegrations(); // reselect channel, resubmit\n  } else throw e;\n}","preventionTips":["Always resolve integration ids from a freshly fetched integrations list","Never hardcode integration ids across environments","Refresh integrations when a channel is reconnected"],"tags":["posts","integration","not-found","validation"],"backgroundTag":"referenced-entity-not-found","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}