{"record":{"id":"032afd4fab98291f","repo":"google-gemini/gemini-cli","slug":"unknown-result-type-from-performinit","errorCode":null,"errorMessage":"Unknown result type from performInit","messagePattern":"Unknown result type from performInit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/a2a-server/src/commands/init.ts","lineNumber":166,"sourceCode":"      case 'message':\n        return this.handleMessageResult(\n          result,\n          context,\n          context.eventBus,\n          taskId,\n          contextId,\n        );\n      case 'submit_prompt':\n        return this.handleSubmitPromptResult(\n          result,\n          context,\n          geminiMdPath,\n          context.eventBus,\n          taskId,\n          contextId,\n        );\n      default:\n        throw new Error('Unknown result type from performInit');\n    }\n  }\n}\n","sourceCodeStart":148,"sourceCodeEnd":170,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/a2a-server/src/commands/init.ts#L148-L170","documentation":"Thrown by the default branch of the switch over result.type in InitCommand.execute. performInit returns a discriminated union with members 'message' and 'submit_prompt'; the switch handles both, so the default is reached only if a future/alternate performInit yields a new type discriminator. This is a version-drift canary.","triggerScenarios":"performInit returns an object whose `type` is neither 'message' nor 'submit_prompt' - e.g. a third action like 'open_editor' added in a newer @google/gemini-cli-core, or a mock returning an unrecognized type in tests.","commonSituations":"Upgrading @google/gemini-cli-core without updating InitCommand to handle a new result type; test mocks that return { type: 'unknown' }.","solutions":["Check the installed @google/gemini-cli-core version's performInit return type and add a case for the new discriminator.","Align a2a-server and @google/gemini-cli-core versions in the workspace (monorepo: run the sync/build step).","In tests, return one of the two known types from the performInit mock.","If unsure which type was returned, log result.type before throwing to diagnose."],"exampleFix":"// before\nswitch (result.type) {\n  case 'message': return this.handleMessageResult(...);\n  case 'submit_prompt': return this.handleSubmitPromptResult(...);\n  default: throw new Error('Unknown result type from performInit');\n}\n\n// after (extensible + diagnostic)\nswitch (result.type) {\n  case 'message': return this.handleMessageResult(...);\n  case 'submit_prompt': return this.handleSubmitPromptResult(...);\n  default:\n    throw new Error(`Unknown result type from performInit: ${JSON.stringify((result as { type?: string }).type)}`);\n}","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['message', 'submit_prompt']);\nif (!KNOWN.has(result.type)) {\n  throw new Error(`performInit returned unrecognized type '${result.type}'; version mismatch.`);\n}","typeGuard":"function isKnownInitResult(r: { type: string }): r is { type: 'message' | 'submit_prompt' } {\n  return r.type === 'message' || r.type === 'submit_prompt';\n}","tryCatchPattern":null,"preventionTips":["Keep a2a-server and @google/gemini-cli-core versions in lockstep in the monorepo.","When upgrading core, grep performInit's return type and add new cases to the switch.","Log result.type before throwing to make future drift obvious.","Add a unit test that performInit's return matches the handled set."],"tags":["init-command","version-drift","discriminated-union","exhaustive-switch"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}