{"record":{"id":"31e778f132f958fa","repo":"paperclipai/paperclip","slug":"gateway-issue-invalid","errorCode":"gateway_issue_invalid","errorMessage":"Gateway issue must belong to the company","messagePattern":"Gateway issue must belong to the company","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":422,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3525,"sourceCode":"      });\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    };\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> {","sourceCodeStart":3507,"sourceCodeEnd":3543,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L3507-L3543","documentation":"assertGatewayContext validation: the issueId supplied for the gateway does not match any issue in the requesting company. The 422 gateway_issue_invalid comes from the company-scoped issues lookup and covers deleted, foreign-company, or malformed issue ids.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select an issue 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"}