{"record":{"id":"e4d89fcece15269f","repo":"dagger/dagger","slug":"failed-to-get-git-attributes-file-contents-w","errorCode":null,"errorMessage":"failed to get git attributes file contents: %w","messagePattern":"failed to get git attributes file contents: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/modulesource.go","lineNumber":2627,"sourceCode":"\t}\n\tgenDirInst := generatedCode.Code\n\n\t// update .gitattributes in the generated context directory\n\tif len(generatedCode.VCSGeneratedPaths) > 0 {\n\t\tgitAttrsPath := filepath.Join(srcInst.Self().SourceSubpath, \".gitattributes\")\n\t\tvar gitAttrsContents []byte\n\t\tvar gitAttrsFile dagql.ObjectResult[*core.File]\n\t\terr = dag.Select(ctx, srcInst.Self().ContextDirectory, &gitAttrsFile, dagql.Selector{\n\t\t\tField: \"file\",\n\t\t\tArgs: []dagql.NamedInput{\n\t\t\t\t{Name: \"path\", Value: dagql.String(gitAttrsPath)},\n\t\t\t},\n\t\t})\n\t\tif err == nil {\n\t\t\tvar contents dagql.String\n\t\t\terr = dag.Select(ctx, gitAttrsFile, &contents, dagql.Selector{Field: \"contents\"})\n\t\t\tif err != nil {\n\t\t\t\treturn res, fmt.Errorf(\"failed to get git attributes file contents: %w\", err)\n\t\t\t}\n\t\t\tgitAttrsContents = []byte(contents)\n\t\t\tif !bytes.HasSuffix(gitAttrsContents, []byte(\"\\n\")) {\n\t\t\t\tgitAttrsContents = append(gitAttrsContents, []byte(\"\\n\")...)\n\t\t\t}\n\t\t}\n\t\tfor _, fileName := range generatedCode.VCSGeneratedPaths {\n\t\t\tif bytes.Contains(gitAttrsContents, []byte(fileName)) {\n\t\t\t\t// already has some config for the file\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfileName := strings.TrimPrefix(fileName, \"/\")\n\t\t\tgitAttrsContents = append(gitAttrsContents,\n\t\t\t\tfmt.Appendf(nil, \"/%s linguist-generated\\n\", fileName)...,\n\t\t\t)\n\t\t}\n\n\t\terr = dag.Select(ctx, genDirInst, &genDirInst,","sourceCodeStart":2609,"sourceCodeEnd":2645,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/modulesource.go#L2609-L2645","documentation":"Thrown by `runCodegen` when reading the contents of the module's existing `.gitattributes` file fails. After codegen produces VCS-generated paths, Dagger reads the existing .gitattributes (if present) to append `linguist-generated` entries; a failure to read contents aborts codegen.","triggerScenarios":"The context directory's `.gitattributes` exists (the `file` select succeeded) but reading its `contents` fails — typically an engine-side blob/storage error, or a race where the file was removed between the existence check and the content read.","commonSituations":"Corrupt or unreadable file blobs in the engine content store; transient engine/LLM-cache storage errors; concurrent modification of the context directory during codegen.","solutions":["Retry the codegen operation (often transient storage/IO).","If persistent, check engine state/store health — restart the engine or clear the local Dagger data dir if blobs are corrupted.","Verify the `.gitattributes` in the module context is a normal readable text file and re-run `dagger develop`."],"exampleFix":"# before: transient failure during dagger develop\n$ dagger develop  # failed to get git attributes file contents\n# after: retry / reset engine store\n$ dagger develop  # succeeds","handlingStrategy":"retry","validationCode":"# ensure the context directory's .gitattributes is a plain readable file\nfile .gitattributes && head .gitattributes","typeGuard":null,"tryCatchPattern":"res, err := s.runCodegen(ctx, srcInst)\nif err != nil && strings.Contains(err.Error(), \"failed to get git attributes file contents\") {\n    // transient storage error: retry once, then inspect engine store\n    return s.runCodegen(ctx, srcInst)\n}","preventionTips":["Keep .gitattributes as a normal text file in the module context.","Avoid concurrent mutation of the module context during develop.","Restart/reset the engine promptly if content-store errors recur."],"tags":["dagger","git","codegen","file-io"],"backgroundTag":"gitattributes-read-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}