{"record":{"id":"482fdc2e6ad0f803","repo":"twpayne/chezmoi","slug":"s-d-w","errorCode":null,"errorMessage":"%s:%d: %w","messagePattern":"%s:%d: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/sourcestate.go","lineNumber":1540,"sourceCode":"\tdir, err := sourceRelPath.Dir().TargetRelPath(\"\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tlineNumber := 0\n\tfor line := range bytes.Lines(data) {\n\t\tlineNumber++\n\t\tline = commentRx.ReplaceAll(line, nil)\n\t\tline = bytes.TrimSpace(line)\n\t\tif len(line) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tinclude := PatternSetInclude\n\t\tline, ok := bytes.CutPrefix(line, []byte{'!'})\n\t\tif ok {\n\t\t\tinclude = PatternSetExclude\n\t\t}\n\t\tif _, err := NewUntrustedRelPath(string(line)); err != nil {\n\t\t\treturn fmt.Errorf(\"%s:%d: %w\", sourceAbsPath, lineNumber, err)\n\t\t}\n\t\tpattern := dir.JoinString(string(line)).String()\n\t\tif err := patternSet.Add(pattern, include); err != nil {\n\t\t\treturn fmt.Errorf(\"%s:%d: %w\", sourceAbsPath, lineNumber, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// addTemplateData adds all template data in sourceAbsPath to s.\nfunc (s *SourceState) addTemplateData(sourceAbsPath AbsPath) error {\n\tformat, err := FormatFromAbsPath(sourceAbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata, err := s.system.ReadFile(sourceAbsPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", sourceAbsPath, err)","sourceCodeStart":1522,"sourceCodeEnd":1558,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/sourcestate.go#L1522-L1558","documentation":"When reading an ignore-file style pattern list (e.g. .chezmoiignore), each line must be a valid relative path. NewUntrustedRelPath rejected the line, and the error is wrapped with the source file and line number so the offending pattern can be located.","triggerScenarios":"A line in .chezmoiignore (or a pattern set file) is not a valid untrusted relative path — e.g. absolute path, empty line content after '!' prefix handling, or illegal path characters — at sourceAbsPath:lineNumber.","commonSituations":"Accidentally adding an absolute pattern like \"/tmp/foo\", patterns with invalid characters, or OS-illegal names (e.g. \"con:\" on Windows) into .chezmoiignore.","solutions":["Fix the offending line at the reported line number to be a plain relative path or glob","Remove absolute paths from the ignore file and use target-relative patterns","Trim stray whitespace/empty entries from pattern lines"],"exampleFix":"# before (.chezmoiignore line 3)\n/tmp/cache\n# after\n.cache/tmp","handlingStrategy":"validation","validationCode":"for i, line := range strings.Split(ignoreFile, \"\\n\") {\n    if _, err := NewUntrustedRelPath(strings.TrimPrefix(line, \"!\")); err != nil {\n        fmt.Printf(\"invalid pattern at line %d: %v\\n\", i+1, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only relative paths/globs in .chezmoiignore","Trim whitespace and remove empty/absolute lines before committing"],"tags":["ignore-file","pattern","path"],"backgroundTag":"invalid-ignore-pattern","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}