grafana/k6 · error
loading feature definitions: %w
Error message
loading feature definitions: %w
What it means
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.
Source
Thrown at internal/cmd/features.go:44
c := &featuresCmd{gs: gs}
cmd := &cobra.Command{
Use: "features",
Short: "List available feature flags",
Long: `List all available feature flags with their lifecycle status and description.`,
Args: cobra.NoArgs,
RunE: c.run,
}
cmd.Flags().BoolVar(&c.isJSON, "json", false, "output in JSON format")
return cmd
}
func (c *featuresCmd) run(_ *cobra.Command, _ []string) error {
all, err := features.All()
if err != nil {
return fmt.Errorf("loading feature definitions: %w", err)
}
if c.isJSON {
return c.printJSON(all)
}
return c.printTable(all)
}
func (c *featuresCmd) printTable(flags []features.Flag) error {
if len(flags) == 0 {
return nil
}
w := tabwriter.NewWriter(c.gs.Stdout, 0, 0, 3, ' ', 0)
if _, err := fmt.Fprintln(w, "FEATURE\tLIFECYCLE\tDESCRIPTION"); err != nil {
return err
}
for _, f := range flags {View on GitHub (pinned to 93accf6570)
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
Defensive patterns
Strategy: validation
Validate before calling
# Sanity-check the binary before relying on it
k6 version >/dev/null && k6 features >/dev/null || { echo 'k6 binary appears broken'; exit 1; } Prevention
- Pin official k6 release hashes in provisioning scripts
- For xk6 builds, run the full test suite (make check) before shipping a custom binary
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- reading --features flag: %w
- error initializing template manager: %w
- Run `k6 cloud login` to authenticate, or check the docs for
- access token not configured
- no project specified. Use --project-id, set K6_CLOUD_PROJECT
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/c5043d6f229cb13a.
Report an issue: GitHub.