{"record":{"id":"60f15193feb2a1b6","repo":"paperclipai/paperclip","slug":"gateway-project-invalid","errorCode":"gateway_project_invalid","errorMessage":"Gateway project must belong to the company","messagePattern":"Gateway project must belong to the company","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":422,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3517,"sourceCode":"  }\n\n  function localStdioTemplateId(connection: typeof toolConnections.$inferSelect): string {\n    const config = asRecord(connection.config) ?? {};\n    const templateId = config.templateId;\n    if (typeof templateId !== \"string\" || templateId.trim().length === 0) {\n      throw new ToolGatewayHttpError(422, \"Local stdio MCP connection requires an approved templateId\", \"local_stdio_template_missing\", {\n        connectionId: connection.id,\n      });\n    }\n    return templateId.trim();\n  }\n\n  async function resolveLocalStdioRuntimeTemplate(connection: typeof toolConnections.$inferSelect): Promise<LocalStdioRuntimeTemplate> {\n    const templateId = localStdioTemplateId(connection);\n    const builtIn = BUILTIN_LOCAL_STDIO_RUNTIME_TEMPLATES[templateId];\n    if (builtIn) return { templateId, ...builtIn };\n    const [template] = await db\n      .select()\n      .from(toolStdioCommandTemplates)\n      .where(and(\n        eq(toolStdioCommandTemplates.companyId, connection.companyId),\n        eq(toolStdioCommandTemplates.templateKey, templateId),\n      ))\n      .limit(1);\n    if (!template || template.status !== \"active\") {\n      throw new ToolGatewayHttpError(422, \"Local stdio MCP connection requires an active approved template\", \"local_stdio_template_invalid\", {\n        connectionId: connection.id,\n        templateId,\n      });\n    }\n    return {\n      templateId,\n      command: template.command,\n      args: template.args ?? [],\n      envKeys: template.envKeys ?? [],\n    };","sourceCodeStart":3499,"sourceCodeEnd":3535,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L3499-L3535","documentation":"assertGatewayContext validation: the projectId supplied for the gateway does not exist in the requesting company. The 422 gateway_project_invalid is thrown from the company-scoped projects lookup, so the project was deleted, mis-typed, or belongs to another tenant.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a project that belongs to the same company as the gateway request."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}