{"id":"1dfeb1b8a00ce73d","repo":"docker/cli","slug":"can-t-save-config-with-empty-filename","errorCode":null,"errorMessage":"can't save config with empty filename","messagePattern":"can't save config with empty filename","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/config/configfile/file.go","lineNumber":199,"sourceCode":"\t// User-Agent header is automatically set, and should not be stored in the configuration\n\tfor v := range c.HTTPHeaders {\n\t\tif strings.EqualFold(v, \"User-Agent\") {\n\t\t\tdelete(c.HTTPHeaders, v)\n\t\t}\n\t}\n\n\tdata, err := json.MarshalIndent(c, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = writer.Write(data)\n\treturn err\n}\n\n// Save encodes and writes out all the authorization information\nfunc (c *ConfigFile) Save() (retErr error) {\n\tif c.Filename == \"\" {\n\t\treturn errors.New(\"can't save config with empty filename\")\n\t}\n\n\tdir := filepath.Dir(c.Filename)\n\tif err := os.MkdirAll(dir, 0o700); err != nil {\n\t\treturn err\n\t}\n\ttemp, err := os.CreateTemp(dir, filepath.Base(c.Filename))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\t// ignore error as the file may already be closed when we reach this.\n\t\t_ = temp.Close()\n\t\tif retErr != nil {\n\t\t\tif err := os.Remove(temp.Name()); err != nil {\n\t\t\t\tlogrus.WithError(err).WithField(\"file\", temp.Name()).Debug(\"Error cleaning up temp file\")\n\t\t\t}\n\t\t}","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/config/configfile/file.go#L181-L217","documentation":"Error \"can't save config with empty filename\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/config/configfile/file.go:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}