{"record":{"id":"04e3d3b12ccbe0d8","repo":"docker/compose","slug":"error-reading-dockerignore-w","errorCode":null,"errorMessage":"error reading .dockerignore: %w","messagePattern":"error reading \\.dockerignore: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/watch/dockerignore.go","lineNumber":159,"sourceCode":"\t\t\treturn p != \"\" && p[0] != '!' // Only keep exclusion patterns\n\t\t})\n\t}\n\n\tpm, err := patternmatcher.New(absPatterns(absRoot, patterns))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &dockerPathMatcher{\n\t\trepoRoot: absRoot,\n\t\tmatcher:  pm,\n\t}, nil\n}\n\nfunc readDockerignorePatterns(r io.Reader) ([]string, error) {\n\tpatterns, err := ignorefile.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading .dockerignore: %w\", err)\n\t}\n\treturn patterns, nil\n}\n\nfunc DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error) {\n\tpatterns, err := ignorefile.ReadAll(strings.NewReader(contents))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading .dockerignore: %w\", err)\n\t}\n\n\treturn NewDockerPatternMatcher(repoRoot, patterns)\n}\n","sourceCodeStart":141,"sourceCodeEnd":172,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/watch/dockerignore.go#L141-L172","documentation":"readDockerignorePatterns feeds the .dockerignore stream into ignorefile.ReadAll, which parses the pattern list line by line. Malformed syntax (e.g. invalid character sequences, broken exclusion patterns) makes ReadAll return an error that is wrapped with this message. This path is used by the watch subsystem to build the path matcher from a live .dockerignore file.","triggerScenarios":"Starting a develop/watch session where the repo's .dockerignore contains lines the dockerignore parser rejects — typically patterns with illegal characters or truncated/corrupted lines (binary junk, CRLF mixed with unusual bytes, or an editor writing invalid UTF-8).","commonSituations":"A .dockerignore corrupted by a merge conflict or an editor that inserted garbage; copy-pasting patterns containing characters the dockerignore grammar does not accept; a file accidentally overwritten with binary content.","solutions":["Open .dockerignore and fix or delete the offending line — the wrapped error usually carries the line number/position.","Validate locally: `docker build .` uses the same parser and will surface the same error quickly.","If the file is mangled beyond repair, regenerate it from git: `git checkout -- .dockerignore`."],"exampleFix":"# before (.dockerignore contains a malformed line)\nsrc/**/tmp\u0000garbage\n# after\nsrc/**/tmp","handlingStrategy":"validation","validationCode":"// lint .dockerignore before starting a watch session\nf, err := os.Open(\".dockerignore\")\nif err == nil {\n    if _, err := ignorefile.ReadAll(f); err != nil {\n        log.Fatalf(\"invalid .dockerignore: %v\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep .dockerignore under version control so corruption is visible in diffs.","Run `docker build .` (same parser) as a quick syntax check after editing .dockerignore.","Avoid editing .dockerignore with tools that can emit invalid UTF-8 or merge-conflict artifacts."],"tags":["go","docker-compose","dockerignore","watch","configuration"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}