{"record":{"id":"c5043d6f229cb13a","repo":"grafana/k6","slug":"loading-feature-definitions-w","errorCode":null,"errorMessage":"loading feature definitions: %w","messagePattern":"loading feature definitions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/features.go","lineNumber":44,"sourceCode":"\tc := &featuresCmd{gs: gs}\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"features\",\n\t\tShort: \"List available feature flags\",\n\t\tLong:  `List all available feature flags with their lifecycle status and description.`,\n\t\tArgs:  cobra.NoArgs,\n\t\tRunE:  c.run,\n\t}\n\n\tcmd.Flags().BoolVar(&c.isJSON, \"json\", false, \"output in JSON format\")\n\n\treturn cmd\n}\n\nfunc (c *featuresCmd) run(_ *cobra.Command, _ []string) error {\n\tall, err := features.All()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"loading feature definitions: %w\", err)\n\t}\n\n\tif c.isJSON {\n\t\treturn c.printJSON(all)\n\t}\n\treturn c.printTable(all)\n}\n\nfunc (c *featuresCmd) printTable(flags []features.Flag) error {\n\tif len(flags) == 0 {\n\t\treturn nil\n\t}\n\n\tw := tabwriter.NewWriter(c.gs.Stdout, 0, 0, 3, ' ', 0)\n\tif _, err := fmt.Fprintln(w, \"FEATURE\\tLIFECYCLE\\tDESCRIPTION\"); err != nil {\n\t\treturn err\n\t}\n\tfor _, f := range flags {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/features.go#L26-L62","documentation":"Returned by the `k6 features` command's run() when features.All() fails. All() reflects over the internal Flags struct and parses the `lifecycle`/`help` struct tags of every feature-flag field; the call fails only when those compile-time tags are malformed (non-kebab name, unknown lifecycle token). This is an invariant of k6's own code, not user input.","triggerScenarios":"Running `k6 features` (optionally --json) on a k6 build whose internal feature-flag struct tags are invalid — essentially only a faulty custom xk6 build or a corrupted binary; no flag value, script, or environment setting influences this path.","commonSituations":"Custom k6 forks/xk6 builds where a developer added a feature flag with a bad tag (e.g. lifecycle:\"beta\" or a field name producing a non-kebab string) and shipped it; virtually never seen in official releases.","solutions":["Reproduce: `k6 features` — if it fails on a stock binary, the binary is corrupted; re-download the official build","If this is your own xk6/extension build, check the Flags struct tags in internal/features/features.go (lifecycle must be experimental|deprecated|ga, names must match the kebab-case regex)","Rebuild from a clean checkout of a released tag and verify `k6 version` matches expectations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Sanity-check the binary before relying on it\nk6 version >/dev/null && k6 features >/dev/null || { echo 'k6 binary appears broken'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin official k6 release hashes in provisioning scripts","For xk6 builds, run the full test suite (make check) before shipping a custom binary"],"tags":["feature-flags","cli","internal"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}