mikefarah/yq · error
failed to parse INI content: %w
Error message
failed to parse INI content: %w
What it means
gopkg.in/ini's LoadSources rejected the input bytes as unparseable INI. The decoder forwards the library's error with %w, so the wrapped text names the actual syntax fault (e.g. missing section header delimiter, unbalanced quotes given the PreserveSurroundedQuote option, or key/value lines without a '=' delimiter).
Source
Thrown at pkg/yqlib/decoder_ini.go:50
func (dec *iniDecoder) Decode() (*CandidateNode, error) {
// If processing is already finished, return io.EOF
if dec.finished {
return nil, io.EOF
}
// Read all content from the stored reader
content, err := io.ReadAll(dec.reader)
if err != nil {
return nil, fmt.Errorf("failed to read INI content: %w", err)
}
// Parse the INI content
loadOpts := ini.LoadOptions{
PreserveSurroundedQuote: dec.prefs.PreserveSurroundedQuote,
}
cfg, err := ini.LoadSources(loadOpts, content)
if err != nil {
return nil, fmt.Errorf("failed to parse INI content: %w", err)
}
// Create a root CandidateNode as a MappingNode (since INI is key-value based)
root := &CandidateNode{
Kind: MappingNode,
Tag: "!!map",
Value: "",
}
// Process each section in the INI file
for _, section := range cfg.Sections() {
sectionName := section.Name()
if sectionName == ini.DefaultSection {
// For the default section, add key-value pairs directly to the root node
for _, key := range section.Keys() {
keyName := key.Name()
keyValue := key.String()View on GitHub (pinned to 8b5af0694b)
Solutions
- Fix the INI syntax reported in the wrapped error (delimiters, quoting, section headers)
- Check that key/value pairs use '=' or ':' separators
- Confirm the file is INI and not a similar format like TOML or .env
- Review ini.LoadOptions (e.g. PreserveSurroundedQuote) if quotes are intentional
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/yqlib/decoder_ini.go:50 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05).
Data as JSON: /api/errors/229e0cb6d5ad52a0.
Report an issue: GitHub.