{"record":{"id":"15146bd99705212b","repo":"JanDeDobbeleer/oh-my-posh","slug":"invalid-yaml","errorCode":null,"errorMessage":"invalid yaml","messagePattern":"invalid yaml","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/segments/argocd.go","lineNumber":80,"sourceCode":"\nfunc (a *Argocd) getConfigFromOpts() string {\n\t// don't exit/panic when encountering invalid flags\n\tflags := cmdflag.NewFlagSet(os.Args[0], cmdflag.ContinueOnError)\n\t// ignore other valid and invalid flags\n\tflags.ParseErrorsAllowlist.UnknownFlags = true\n\t// only care about config\n\tflags.String(\"config\", \"\", \"get config from opts\")\n\n\topts := a.env.Getenv(argocdOptsEnv)\n\t_ = flags.Parse(strings.Split(opts, \" \"))\n\treturn flags.Lookup(\"config\").Value.String()\n}\n\nfunc (a *Argocd) parseConfig(file string) (bool, error) {\n\tconfig := a.env.FileContent(file)\n\t// missing or empty file content\n\tif config == \"\" {\n\t\treturn false, errors.New(argocdInvalidYaml)\n\t}\n\n\tvar data ArgocdConfig\n\terr := yaml.Unmarshal([]byte(config), &data)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn false, errors.New(argocdInvalidYaml)\n\t}\n\ta.Name = data.CurrentContext\n\tfor _, context := range data.Contexts {\n\t\tif context.Name == a.Name {\n\t\t\t// mandatory fields in yaml\n\t\t\tif context.Server == \"\" || context.User == \"\" {\n\t\t\t\treturn false, errors.New(argocdInvalidYaml)\n\t\t\t}\n\t\t\ta.Server = context.Server\n\t\t\ta.User = context.User\n\t\t\treturn true, nil","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/argocd.go#L62-L98","documentation":"The argocd segment parses the Argo CD CLI config file (~/.config/argocd/config or the file from --config/ARGOCD_OPTS). parseConfig first reads the file content; if the file is missing or empty, it returns 'invalid yaml' because there is nothing to unmarshal. The segment then disables itself.","triggerScenarios":"argocd segment Enabled() runs, getConfigPath() resolves to a path that does not exist (never ran `argocd login`), or the file exists but is empty (zero bytes).","commonSituations":"Argo CD installed but never logged in so no config file was written; ARGOCD_OPTS pointing --config at a nonexistent file; a fresh machine/container without ~/.config/argocd/config.","solutions":["Run `argocd login <server>` to generate ~/.config/argocd/config, or create the file manually if that is all you need.","Remove or disable the argocd segment in your theme if you do not use Argo CD on this machine.","If you intend a custom config, verify the path from ARGOCD_OPTS (--config=...) actually exists and is non-empty."],"exampleFix":"# before - no config file\n$ ls ~/.config/argocd/config\nNo such file\n\n# after\n$ argocd login argocd.example.com --username me\n# creates ~/.config/argocd/config","handlingStrategy":"validation","validationCode":"test -s ~/.config/argocd/config && echo \"argocd config present\" || echo \"run 'argocd login' first\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `argocd login` on every machine where you enable the argocd segment","Check that any --config file given via ARGOCD_OPTS exists and is non-empty","Disable the argocd segment on machines that don't use Argo CD"],"tags":["argocd","config-file","segment"],"backgroundTag":"missing-config-file","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}