kubernetes/kops · error
unable to parse JSON %v: %v
Error message
unable to parse JSON %v: %v
What it means
RunCreateSecretDockerConfig json.Unmarshals the read Docker config bytes to validate them; this fires when the content is not valid JSON. The file/stdin read succeeded, but the content fails JSON validation before being stored.
Source
Thrown at cmd/kops/create_secret_dockerconfig.go:125
}
var data []byte
if options.DockerConfigPath == "-" {
data, err = ConsumeStdin()
if err != nil {
return fmt.Errorf("reading Docker config from stdin: %v", err)
}
} else {
data, err = os.ReadFile(options.DockerConfigPath)
if err != nil {
return fmt.Errorf("reading Docker config %v: %v", options.DockerConfigPath, err)
}
}
var parsedData map[string]interface{}
err = json.Unmarshal(data, &parsedData)
if err != nil {
return fmt.Errorf("unable to parse JSON %v: %v", options.DockerConfigPath, err)
}
secret := &fi.Secret{
Data: data,
}
if !options.Force {
_, created, err := secretStore.GetOrCreateSecret(ctx, "dockerconfig", secret)
if err != nil {
return fmt.Errorf("adding dockerconfig secret: %v", err)
}
if !created {
return fmt.Errorf("failed to create the dockerconfig secret as it already exists. Pass the `--force` flag to replace an existing secret")
}
} else {
_, err := secretStore.ReplaceSecret("dockerconfig", secret)
if err != nil {
return fmt.Errorf("updating dockerconfig secret: %v", err)View on GitHub (pinned to 4c8573c808)
Solutions
- Check the Docker config file for JSON syntax errors
- Ensure the file is a Docker config.json (or its dockercfg JSON variant), not a YAML or text file
- Validate with an external JSON linter and retry
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/kops/create_secret_dockerconfig.go:125 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/9c27f588b3c03acc.
Report an issue: GitHub.