{"record":{"id":"a9a2caf5fa79c29b","repo":"paperclipai/paperclip","slug":"gateway-profile-invalid","errorCode":"gateway_profile_invalid","errorMessage":"Gateway profile must belong to the company","messagePattern":"Gateway profile must belong to the company","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":422,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":6455,"sourceCode":"    companyId: string;\n    profileId?: string | null;\n    agentId?: string | null;\n    projectId?: string | null;\n    issueId?: string | null;\n  }) {\n    if (input.profileId) {\n      const [profile] = await db\n        .select({ id: toolProfiles.id })\n        .from(toolProfiles)\n        .where(\n          and(\n            eq(toolProfiles.companyId, input.companyId),\n            eq(toolProfiles.id, input.profileId),\n          ),\n        )\n        .limit(1);\n      if (!profile)\n        throw new ToolGatewayHttpError(\n          422,\n          \"Gateway profile must belong to the company\",\n          \"gateway_profile_invalid\",\n        );\n    }\n    if (input.agentId)\n      await assertAgentInCompany(input.companyId, input.agentId);\n    if (input.projectId) {\n      const [project] = await db\n        .select({ id: projects.id })\n        .from(projects)\n        .where(\n          and(\n            eq(projects.companyId, input.companyId),\n            eq(projects.id, input.projectId),\n          ),\n        )\n        .limit(1);","sourceCodeStart":6437,"sourceCodeEnd":6473,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L6437-L6473","documentation":"assertGatewayContext validation: the profileId supplied when creating/updating a gateway does not resolve to a tool profile in the same company. The 422 gateway_profile_invalid fires on the company-scoped select, catching both nonexistent ids and ids leaked from another company.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3367 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a gateway profile that belongs to the same company as the request."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}