{"record":{"id":"7e1d32c1d62ff9a8","repo":"JanDeDobbeleer/oh-my-posh","slug":"section-does-not-exist","errorCode":null,"errorMessage":"section does not exist: ","messagePattern":"section does not exist: ","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ini/ini.go","lineNumber":121,"sourceCode":"\tf.sections[name] = section\n\tf.order = append(f.order, section)\n\n\treturn section\n}\n\n// Sections returns all sections in file order, including the unnamed default\n// section.\nfunc (f *File) Sections() []*Section {\n\treturn f.order\n}\n\n// GetSection returns the named section, or an error when it doesn't exist.\nfunc (f *File) GetSection(name string) (*Section, error) {\n\tif section, ok := f.sections[name]; ok {\n\t\treturn section, nil\n\t}\n\n\treturn nil, errors.New(\"section does not exist: \" + name)\n}\n\n// Section returns the named section, or an empty one when it doesn't exist.\nfunc (f *File) Section(name string) *Section {\n\tif section, ok := f.sections[name]; ok {\n\t\treturn section\n\t}\n\n\treturn &Section{name: name, keys: make(map[string]*Key)}\n}\n\nfunc (s *Section) Name() string {\n\treturn s.name\n}\n\n// Keys returns the section's keys in file order.\nfunc (s *Section) Keys() []*Key {\n\treturn s.order","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/ini/ini.go#L103-L139","documentation":"GetSection performs a strict lookup: it returns the *Section only if the named section exists in the parsed file, otherwise it errors. It exists for callers that must distinguish 'missing section' from 'empty section'; the lenient Section() method returns an empty section instead.","triggerScenarios":"Calling GetSection(name) when the file was parsed without that section - e.g. resolveUpstream or copySection asks for a section like [upstream] or [segments] that isn't present in the user's config.","commonSituations":"A config file predating a feature (missing [upgrade] or [palette] section); typo in section name; code assuming a section always exists because a newer config version includes it.","solutions":["Check with Section(name) or a contains-style check first and treat absence as default/empty","Add the missing section to the config file, e.g. [palette]","If the section is optional, switch to the lenient Section() accessor"],"exampleFix":"// before\nsection, err := file.GetSection(\"palette\")\nif err != nil { return err }\n// after\nsection := file.Section(\"palette\") // empty section if absent","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func hasSection(f *ini.File, name string) bool {\n    _, err := f.GetSection(name)\n    return err == nil\n}","tryCatchPattern":"section, err := file.GetSection(\"palette\")\nif err != nil {\n    section = ini.NewEmptySection(\"palette\") // or file.Section(\"palette\")\n}","preventionTips":["Prefer the lenient Section() accessor when a section is optional","Document required sections for consumers of the config","Version-check configs and add missing sections during migration"],"tags":["ini","config","lookup","missing-key"],"backgroundTag":"missing-config-section","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}