{"record":{"id":"5d8797d3fdf969e2","repo":"paperclipai/paperclip","slug":"gateway-issue-project-mismatch","errorCode":"gateway_issue_project_mismatch","errorMessage":"Gateway issue must belong to the selected project","messagePattern":"Gateway issue must belong to the selected project","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":422,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3527,"sourceCode":"    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    };\n  }\n\n  async function localStdioEnvironment(\n    session: ToolGatewaySession,\n    connection: typeof toolConnections.$inferSelect,\n    template: LocalStdioRuntimeTemplate,\n    grant: typeof connectionGrants.$inferSelect,\n  ): Promise<NodeJS.ProcessEnv> {\n    const env: NodeJS.ProcessEnv = {};\n    for (const key of [\"PATH\", \"Path\", \"SystemRoot\", \"WINDIR\", \"COMSPEC\", \"PATHEXT\"]) {","sourceCodeStart":3509,"sourceCodeEnd":3545,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L3509-L3545","documentation":"assertGatewayContext consistency check: the issue exists in the company but its projectId does not equal the projectId selected for the gateway. The 422 gateway_issue_project_mismatch prevents binding a gateway to an issue outside the chosen project scope; align the issue/project pair.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3386 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose an issue within the selected project, or omit the project filter."],"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-14T00:17:10.932Z"}