grafana/k6 · error

failed to get version details with extensions

Error message

failed to get version details with extensions: %w

What it means

Generic wrapper in versionCmd.run around versionDetailsWithExtensions; the real cause is typically the 'unhandled extension type' guard firing while collecting extension metadata for 'k6 version --json'.

Solutions

  1. Look at the wrapped error — for unhandled extension type, upgrade k6 or rebuild the xk6 binary with compatible extensions
  2. Run plain 'k6 version' (non-JSON) which does not enumerate extensions
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/cmd/version.go:229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/8f25788ea92c4bf6. Report an issue: GitHub.

Appendix: source

Thrown at internal/cmd/version.go:229

	return details, nil
}

type versionCmd struct {
	gs     *state.GlobalState
	isJSON bool
}

func (c *versionCmd) run(cmd *cobra.Command, _ []string) error {
	if !c.isJSON {
		root := cmd.Root()
		root.SetArgs([]string{"--version"})
		_ = root.Execute()
		return nil
	}

	details, err := versionDetailsWithExtensions(ext.GetAll())
	if err != nil {
		return fmt.Errorf("failed to get version details with extensions: %w", err)
	}

	if err := json.NewEncoder(c.gs.Stdout).Encode(details); err != nil {
		return fmt.Errorf("failed to encode/output version details: %w", err)
	}

	return nil
}

func getCmdVersion(gs *state.GlobalState) *cobra.Command {
	versionCmd := &versionCmd{gs: gs}

	cmd := &cobra.Command{
		Use:    "version",
		Short:  "Show application version",
		Long:   `Show the application version and exit.`,
		Hidden: true,
		RunE:   versionCmd.run,

View on GitHub (pinned to 01ffac6f24)