{"record":{"id":"8f25788ea92c4bf6","repo":"grafana/k6","slug":"failed-to-get-version-details-with-extensions-w","errorCode":null,"errorMessage":"failed to get version details with extensions: %w","messagePattern":"failed to get version details with extensions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/version.go","lineNumber":229,"sourceCode":"\treturn details, nil\n}\n\ntype versionCmd struct {\n\tgs     *state.GlobalState\n\tisJSON bool\n}\n\nfunc (c *versionCmd) run(cmd *cobra.Command, _ []string) error {\n\tif !c.isJSON {\n\t\troot := cmd.Root()\n\t\troot.SetArgs([]string{\"--version\"})\n\t\t_ = root.Execute()\n\t\treturn nil\n\t}\n\n\tdetails, err := versionDetailsWithExtensions(ext.GetAll())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get version details with extensions: %w\", err)\n\t}\n\n\tif err := json.NewEncoder(c.gs.Stdout).Encode(details); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode/output version details: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc getCmdVersion(gs *state.GlobalState) *cobra.Command {\n\tversionCmd := &versionCmd{gs: gs}\n\n\tcmd := &cobra.Command{\n\t\tUse:    \"version\",\n\t\tShort:  \"Show application version\",\n\t\tLong:   `Show the application version and exit.`,\n\t\tHidden: true,\n\t\tRunE:   versionCmd.run,","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/version.go#L211-L247","documentation":"'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.","triggerScenarios":"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.","commonSituations":"Custom xk6 builds after adding a new extension kind; using --json to debug extension loading and hitting the classification failure.","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"],"exampleFix":"# before\nk6 version --json   # fails on unknown extension type\n# after\nk6 version           # plain output still works","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"# Fall back to the plain banner when JSON collection fails\nk6 version --json || { echo 'JSON version details failed, using plain output' >&2; k6 version; }","preventionTips":["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"],"tags":["extensions","version","cli","json"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}