JanDeDobbeleer/oh-my-posh · error
section does not exist:
Error message
section does not exist:
What it means
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.
Source
Thrown at src/ini/ini.go:121
f.sections[name] = section
f.order = append(f.order, section)
return section
}
// Sections returns all sections in file order, including the unnamed default
// section.
func (f *File) Sections() []*Section {
return f.order
}
// GetSection returns the named section, or an error when it doesn't exist.
func (f *File) GetSection(name string) (*Section, error) {
if section, ok := f.sections[name]; ok {
return section, nil
}
return nil, errors.New("section does not exist: " + name)
}
// Section returns the named section, or an empty one when it doesn't exist.
func (f *File) Section(name string) *Section {
if section, ok := f.sections[name]; ok {
return section
}
return &Section{name: name, keys: make(map[string]*Key)}
}
func (s *Section) Name() string {
return s.name
}
// Keys returns the section's keys in file order.
func (s *Section) Keys() []*Key {
return s.orderView on GitHub (pinned to 0976794618)
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
Example fix
// before
section, err := file.GetSection("palette")
if err != nil { return err }
// after
section := file.Section("palette") // empty section if absent Defensive patterns
Strategy: type-guard
Type guard
func hasSection(f *ini.File, name string) bool {
_, err := f.GetSection(name)
return err == nil
} Try / catch
section, err := file.GetSection("palette")
if err != nil {
section = ini.NewEmptySection("palette") // or file.Section("palette")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unclosed section:
- key-value delimiter not found:
- invalid export format
- missing Brewfather user id (user_id)
- missing Brewfather api key (api_key)
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/7e1d32c1d62ff9a8.
Report an issue: GitHub.