{"record":{"id":"4d4089dd49b6a7b1","repo":"can1357/oh-my-pi","slug":"security-scan-requires-the-session-model-and-authe","errorCode":null,"errorMessage":"Security scan requires the session model and authentication registries","messagePattern":"Security scan requires the session model and authentication registries","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/security-scan.ts","lineNumber":127,"sourceCode":"\treadonly loadMode = \"discoverable\";\n\treadonly summary = \"Run OMP-native scans and explicit Codex Security cloud operations\";\n\treadonly description = securityScanDescription.trim();\n\treadonly parameters = securityScanSchema;\n\treadonly strict = true;\n\n\tconstructor(readonly session: ToolSession) {}\n\n\tasync execute(\n\t\t_toolCallId: string,\n\t\tparams: SecurityScanParams,\n\t\tsignal?: AbortSignal,\n\t): Promise<AgentToolResult<SecurityScanToolDetails>> {\n\t\tif (!this.session.settings.get(\"security.enabled\")) {\n\t\t\tthrow new ToolError(\"Security is disabled. Enable security.enabled before using security_scan.\");\n\t\t}\n\t\tconst coordinatorForSession = () => {\n\t\t\tif (!this.session.modelRegistry || !this.session.authStorage) {\n\t\t\t\tthrow new ToolError(\"Security scan requires the session model and authentication registries\");\n\t\t\t}\n\t\t\treturn getSecurityCoordinator({\n\t\t\t\tcwd: this.session.cwd,\n\t\t\t\tsettings: this.session.settings,\n\t\t\t\tauthStorage: this.session.authStorage,\n\t\t\t\tmodelRegistry: this.session.modelRegistry,\n\t\t\t\tactiveModel: this.session.getActiveModel?.(),\n\t\t\t\tsessionId: this.session.getSessionId?.() ?? undefined,\n\t\t\t\tagentId: this.session.getAgentId?.() ?? undefined,\n\t\t\t\tasyncJobManager: this.session.asyncJobManager,\n\t\t\t});\n\t\t};\n\t\tswitch (params.action) {\n\t\t\tcase \"preflight\": {\n\t\t\t\tconst model = this.session.getActiveModel?.();\n\t\t\t\tconst plan = await coordinatorForSession().preflight({\n\t\t\t\t\ttarget: targetFromParams(params),\n\t\t\t\t\tknowledgeBasePaths: params.knowledge_base_paths,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/security-scan.ts#L109-L145","documentation":"Beyond the security.enabled gate, the coordinator needs two session registries: modelRegistry (to run scan planning against a model) and authStorage. coordinatorForSession throws this ToolError when either is missing on the ToolSession. It is raised for all coordinator-backed actions (preflight, start, status, cancel) as well as execute.","triggerScenarios":"Calling any security_scan action that builds a coordinator while session.modelRegistry or session.authStorage is null/undefined — typically a session constructed by an SDK embedder or test harness that did not attach both registries.","commonSituations":"Custom integrations constructing ToolSession manually; test fixtures with stub sessions lacking registries; running in environments where model registry bootstrap failed or auth storage is unavailable.","solutions":["Construct the session through the standard bootstrap so both modelRegistry and authStorage are populated.","If embedding, pass an initialized model registry and auth storage into the session factory.","For tests, provide stub registries that satisfy the session interface before invoking the tool."],"exampleFix":"// before\nconst session = { cwd, settings } as ToolSession;\n// after\nconst session = { cwd, settings, modelRegistry, authStorage } satisfies ToolSession;","handlingStrategy":"validation","validationCode":"if (!session.modelRegistry || !session.authStorage) throw new Error(\"security_scan needs modelRegistry and authStorage on the session\");","typeGuard":"function securityReady(s: ToolSession): boolean { return Boolean(s.modelRegistry && s.authStorage); }","tryCatchPattern":"try { return await tool.execute(id, params); } catch (e) { if (e instanceof ToolError && e.message.includes(\"model and authentication registries\")) { /* re-bootstrap session registries */ } throw e; }","preventionTips":["Use the canonical session constructor rather than hand-rolled ToolSession objects.","In test harnesses, include stub modelRegistry/authStorage in the base session fixture.","Assert registry presence in a preflight helper shared by all tool dispatchers."],"tags":["configuration","tooling","initialization"],"backgroundTag":"missing-session-registry","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}