{"record":{"id":"4da9028e96586901","repo":"hashicorp/nomad","slug":"failed-to-parse-auth-config-file-v","errorCode":null,"errorMessage":"Failed to parse auth config file: %v","messagePattern":"Failed to parse auth config file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/utils.go","lineNumber":75,"sourceCode":"func dockerImageRef(repo string, tag string) string {\n\tif tag == \"\" {\n\t\treturn repo\n\t}\n\treturn fmt.Sprintf(\"%s:%s\", repo, tag)\n}\n\n// loadDockerConfig loads the docker config at the specified path, returning an\n// error if it couldn't be read.\nfunc loadDockerConfig(file string) (*configfile.ConfigFile, error) {\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to open auth config file: %v, error: %v\", file, err)\n\t}\n\tdefer f.Close()\n\n\tcfile := new(configfile.ConfigFile)\n\tif err = cfile.LoadFromReader(f); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to parse auth config file: %v\", err)\n\t}\n\treturn cfile, nil\n}\n\n// repositoryInfo contains the subset of repository metadata needed for auth\n// lookup against Docker config files and credential helpers.\ntype repositoryInfo struct {\n\tIndex *registrytypes.IndexInfo\n}\n\n// parseRepositoryInfo takes a repo and returns the repository metadata needed\n// for interacting with a Docker config object.\nfunc parseRepositoryInfo(repo string) (*repositoryInfo, error) {\n\tname, err := reference.ParseNormalizedNamed(repo)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to parse named repo %q: %v\", repo, err)\n\t}\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/utils.go#L57-L93","documentation":"After successfully opening the auth config file, loadDockerConfig parses it with configfile.LoadFromReader. If the contents are not valid Docker config JSON, the error is wrapped as 'Failed to parse auth config file'. The file exists but its content is unusable for auth lookups.","triggerScenarios":"cfile.LoadFromReader(f) fails: file contains invalid JSON, is empty when auth is expected, was truncated by a failed write, or contains YAML/credentials format instead of Docker's config.json schema.","commonSituations":"Manually edited config.json with syntax errors; pasting a raw 'auths' value instead of the full config document; half-written file from an interrupted docker login; templating engine rendering invalid output.","solutions":["Validate the file content against Docker's config.json schema (try: docker login then diff, or jq . file)","Fix JSON syntax errors (trailing commas, quotes) or regenerate via docker login","Replace YAML-style or partial credential content with a complete {\"auths\":{...}} document","Rewrite the file atomically (write temp file then rename) to avoid truncated reads"],"exampleFix":"// before\n{ \"auths\": { \"registry.example.com\": {\"auth\": \"...\",} } }\n// after\n{ \"auths\": { \"registry.example.com\": {\"auth\": \"...\"} } }","handlingStrategy":"validation","validationCode":"raw, err := os.ReadFile(dockerAuthPath)\nif err != nil { return err }\nvar probe map[string]json.RawMessage\nif err := json.Unmarshal(raw, &probe); err != nil {\n    return fmt.Errorf(\"docker auth config is not valid JSON: %w\", err)\n}\nif _, ok := probe[\"auths\"]; !ok {\n    return errors.New(\"docker auth config missing 'auths' key\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate config.json with jq in CI before deploying","Paste complete docker config documents, not just auth fragments","Regenerate via docker login instead of hand-editing","Write files atomically to avoid truncated reads"],"tags":["docker","auth","json-parse","config-file"],"backgroundTag":"auth-config-file-unreadable","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}