grafana/k6 · error
failed to get version details with extensions: %w
Error message
failed to get version details with extensions: %w
What it means
'k6 version --json' collects version details including all registered extensions via versionDetailsWithExtensions; if that collection fails (today, the 'unhandled extension type' guard), the error is wrapped as "failed to get version details with extensions" and no JSON is produced.
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 93accf6570)
Solutions
- Run plain 'k6 version' — the non-JSON path prints the banner without iterating extension types
- Rebuild k6 so the version command handles the new extension type, or drop the problematic extension from the build
- Report upstream with the plain 'k6 version' output and the extension list
Example fix
# before k6 version --json # fails on unknown extension type # after k6 version # plain output still works
Defensive patterns
Strategy: fallback
Try / catch
# Fall back to the plain banner when JSON collection fails
k6 version --json || { echo 'JSON version details failed, using plain output' >&2; k6 version; } Prevention
- Use plain 'k6 version' for quick checks
- Keep the extension set consistent with the k6 core version
- Report unknown-type errors upstream with the full plain version output
When it happens
Trigger: Running 'k6 version --json' on a binary whose registered extensions include a type unknown to the version command; the wrapping happens at the call site in versionCmd.run.
Common situations: Custom xk6 builds after adding a new extension kind; using --json to debug extension loading and hitting the classification failure.
Related errors
- failed to encode load zone list: %w
- failed to encode test list: %w
- failed to encode project list: %w
- unhandled extension type: %s
- failed to encode/output version details: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/8f25788ea92c4bf6.
Report an issue: GitHub.