grafana/k6 · error
couldn't parse the configuration from
Error message
couldn't parse the configuration from %q: %w
What it means
Wrapped error from readDiskConfig: the config file was read successfully but could not be parsed — invalid JSON or values that don't unmarshal into the Config struct.
Solutions
- Validate the JSON syntax of the config file with a JSON linter
- Ensure option values match their expected types (e.g. durations as strings like '30s')
- Remove or fix the offending key reported by the wrapped error
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/cmd/config.go:153 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/bfeaf42e6c7dc2fc.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/config.go:156
func readDiskConfig(gs *state.GlobalState) (Config, error) {
// Try to see if the file exists in the supplied filesystem
if _, err := gs.FS.Stat(gs.Flags.ConfigFilePath); err != nil {
if errors.Is(err, fs.ErrNotExist) && gs.Flags.ConfigFilePath == gs.DefaultFlags.ConfigFilePath {
// If the file doesn't exist, but it was the default config file (i.e. the user
// didn't specify anything), silence the error
err = nil
}
return Config{}, err
}
data, err := fsext.ReadFile(gs.FS, gs.Flags.ConfigFilePath)
if err != nil {
return Config{}, fmt.Errorf("couldn't load the configuration from %q: %w", gs.Flags.ConfigFilePath, err)
}
var conf Config
err = json.Unmarshal(data, &conf)
if err != nil {
return Config{}, fmt.Errorf("couldn't parse the configuration from %q: %w", gs.Flags.ConfigFilePath, err)
}
return conf, nil
}
// Permissions for the on-disk config file and its containing directory.
// The config can contain the Grafana Cloud API token (collectors.cloud.token),
// so it must not be readable by other local users.
const (
configFileMode = fs.FileMode(0o600)
configDirMode = fs.FileMode(0o700)
)
// writeDiskConfig serializes the configuration to a JSON file and writes it in the supplied
// location on the supplied filesystem.
//
// The file may contain the Grafana Cloud API token, so it is written with
// owner-only permissions (0o600), inside a directory created with owner-only
// permissions (0o700). If the file or directory already exists with looserView on GitHub (pinned to 3fcf5388d7)