google-gemini/gemini-cli · error · Error

Unknown result type from performInit

Error message

Unknown result type from performInit

What it means

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.

Source

Thrown at packages/a2a-server/src/commands/init.ts:166

      case 'message':
        return this.handleMessageResult(
          result,
          context,
          context.eventBus,
          taskId,
          contextId,
        );
      case 'submit_prompt':
        return this.handleSubmitPromptResult(
          result,
          context,
          geminiMdPath,
          context.eventBus,
          taskId,
          contextId,
        );
      default:
        throw new Error('Unknown result type from performInit');
    }
  }
}

View on GitHub (pinned to 5024443c72)

Solutions

  1. Check the installed @google/gemini-cli-core version's performInit return type and add a case for the new discriminator.
  2. Align a2a-server and @google/gemini-cli-core versions in the workspace (monorepo: run the sync/build step).
  3. In tests, return one of the two known types from the performInit mock.
  4. If unsure which type was returned, log result.type before throwing to diagnose.

Example fix

// before
switch (result.type) {
  case 'message': return this.handleMessageResult(...);
  case 'submit_prompt': return this.handleSubmitPromptResult(...);
  default: throw new Error('Unknown result type from performInit');
}

// after (extensible + diagnostic)
switch (result.type) {
  case 'message': return this.handleMessageResult(...);
  case 'submit_prompt': return this.handleSubmitPromptResult(...);
  default:
    throw new Error(`Unknown result type from performInit: ${JSON.stringify((result as { type?: string }).type)}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = new Set(['message', 'submit_prompt']);
if (!KNOWN.has(result.type)) {
  throw new Error(`performInit returned unrecognized type '${result.type}'; version mismatch.`);
}

Type guard

function isKnownInitResult(r: { type: string }): r is { type: 'message' | 'submit_prompt' } {
  return r.type === 'message' || r.type === 'submit_prompt';
}

Prevention

When it happens

Trigger: 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.

Common situations: Upgrading @google/gemini-cli-core without updating InitCommand to handle a new result type; test mocks that return { type: 'unknown' }.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/032afd4fab98291f. Report an issue: GitHub.