{"record":{"id":"48dc2fac264413c9","repo":"grafana/k6","slug":"failed-to-load-the-configuration-file-from-the-loc-48dc2f","errorCode":null,"errorMessage":"failed to load the configuration file from the local file system: %w","messagePattern":"failed to load the configuration file from the local file system: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/features.go","lineNumber":105,"sourceCode":"\tenc.SetIndent(\"\", \"  \")\n\treturn enc.Encode(out)\n}\n\nfunc resolveFeatureFlags(gs *state.GlobalState, cmd *cobra.Command, piState *lib.TestPreInitState) error {\n\tvar cli features.Source\n\tif cmd.Flags().Lookup(\"features\") != nil {\n\t\tcli.Supplied = cmd.Flags().Changed(\"features\")\n\t\tvals, err := cmd.Flags().GetStringArray(\"features\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading --features flag: %w\", err)\n\t\t}\n\t\tcli.Values = vals\n\t}\n\n\tfileConf, err := readDiskConfig(gs)\n\tif err != nil {\n\t\treturn errext.WithExitCodeIfNone(\n\t\t\tfmt.Errorf(\"failed to load the configuration file from the local file system: %w\", err),\n\t\t\texitcodes.InvalidConfig,\n\t\t)\n\t}\n\tjsonSurface := features.Source{Values: fileConf.Features, Supplied: fileConf.Features != nil}\n\n\tenvSurface := maps.Clone(gs.Env)\n\tif envSurface == nil {\n\t\tenvSurface = make(map[string]string)\n\t}\n\tmaps.Copy(envSurface, piState.RuntimeOptions.Env)\n\n\tflags, err := features.Init(gs.Logger, cli, jsonSurface, envSurface)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"initializing feature flags: %w\", err)\n\t}\n\tpiState.FeatureFlags = flags\n\n\tfor _, name := range flags.Activated() {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/features.go#L87-L123","documentation":"Emitted by resolveFeatureFlags (the shared pre-init path for feature flags) when readDiskConfig fails while resolving the JSON-config surface for features. It wraps the same readDiskConfig errors as getConsolidatedConfig does — unreadable file (I/O) or invalid JSON — and attaches exit code InvalidConfig.","triggerScenarios":"Running a command that pre-resolves feature flags with a --config/K6_CONFIG/default config file that exists but cannot be read or does not parse as JSON; the features-specific surfaces (CLI --features, K6_FEATURES-style env, runtime env) are merged only after this read succeeds.","commonSituations":"Same root causes as the other config errors: hand-edited k6.json with a trailing comma, permission-restricted config, or a CI-baked broken file — surfacing here even before script loading because feature flags are resolved in the test's pre-init state.","solutions":["Read the inner wrapped error — it names the config path and whether the failure is I/O (\"couldn't load\") or JSON (\"couldn't parse\")","Fix permissions for I/O failures; fix JSON syntax with `jq . <path>` for parse failures","Pass feature flags via CLI/env only and point --config at a known-good file to confirm the config is the culprit","Or remove/repair the config file so the default path is either valid JSON or absent (absent default is silently ignored)"],"exampleFix":"# before\n$ k6 run script.js --log-output=stdout\n# error: failed to load the configuration file from the local file system: couldn't parse ...\n\n# after\n$ jq . ~/.config/loadimpact/k6.json  # fix reported syntax error, then\n$ k6 run script.js","handlingStrategy":"validation","validationCode":"# Validate config JSON ahead of any feature-flag-driven run\ncfg=\"${K6_CONFIG:-$HOME/.config/loadimpact/k6.json}\"\n[ ! -f \"$cfg\" ] || jq -e . \"$cfg\" >/dev/null || { echo \"fix $cfg\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the features array in config JSON short and name-checked against `k6 features`","Lint the config whenever the file changes in a branch","Treat exit code 104 from early startup as a config-file defect, not a script defect"],"tags":["config","feature-flags","json","exit-code"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}