{"record":{"id":"dfcae7f69d2299de","repo":"dagger/dagger","slug":"failed-to-add-vcs-generated-file-w","errorCode":null,"errorMessage":"failed to add vcs generated file: %w","messagePattern":"failed to add vcs generated file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/modulesource.go","lineNumber":2656,"sourceCode":"\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,\n\t\t\tdagql.Selector{\n\t\t\t\tField: \"withNewFile\",\n\t\t\t\tArgs: []dagql.NamedInput{\n\t\t\t\t\t{Name: \"path\", Value: dagql.String(gitAttrsPath)},\n\t\t\t\t\t{Name: \"contents\", Value: dagql.String(gitAttrsContents)},\n\t\t\t\t\t{Name: \"permissions\", Value: dagql.Int(0o600)},\n\t\t\t\t},\n\t\t\t},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn res, fmt.Errorf(\"failed to add vcs generated file: %w\", err)\n\t\t}\n\t}\n\n\t// update .gitignore in the generated context directory\n\twriteGitignore := true // default to true if not set\n\tif srcInst.Self().CodegenConfig != nil && srcInst.Self().CodegenConfig.AutomaticGitignore != nil {\n\t\twriteGitignore = *srcInst.Self().CodegenConfig.AutomaticGitignore\n\t}\n\tvcsIgnoredPaths := generatedCode.VCSIgnoredPaths\n\tif srcInst.Self().ConfigFilename == modules.Filename {\n\t\t// toml modules build from committed generated files: gitignoring them\n\t\t// would filter them out of the local module context.\n\t\tvcsIgnoredPaths = slices.DeleteFunc(slices.Clone(vcsIgnoredPaths), func(ignore string) bool {\n\t\t\treturn ignoresGeneratedPath(ignore, generatedCode.VCSGeneratedPaths)\n\t\t})\n\t}\n\tif writeGitignore && len(vcsIgnoredPaths) > 0 {\n\t\tgitIgnorePath := filepath.Join(srcInst.Self().SourceSubpath, \".gitignore\")","sourceCodeStart":2638,"sourceCodeEnd":2674,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/modulesource.go#L2638-L2674","documentation":"Thrown by `runCodegen` when appending the updated `.gitattributes` (marking SDK-generated paths as `linguist-generated`) into the generated code directory fails via the `withNewFile` dagql select. The codegen result directory could not be modified.","triggerScenarios":"Codegen produced VCSGeneratedPaths and the `withNewFile` select on the generated directory errored — engine-side directory mutation failure, invalid path for the generated file, or an inner dagql error from the select chain.","commonSituations":"Engine storage/IO failures; path conflicts (e.g. a directory exists where the .gitattributes file should be written); bugs in custom SDKs returning invalid VCSGeneratedPaths entries.","solutions":["Inspect the wrapped inner error for the concrete dagql/IO failure and fix that.","Check that no directory conflicts with the `.gitattributes` path inside the module source subpath.","Validate the SDK's returned VCSGeneratedPaths (no empty/invalid names) if using a custom SDK.","Retry after restarting the engine if the error indicates transient storage failure."],"exampleFix":"// before: SDK returns generated paths with invalid characters\nVCSGeneratedPaths: [\"sdk/../evil\"]\n// after\nVCSGeneratedPaths: [\"sdk/**\"]\n$ dagger develop","handlingStrategy":"try-catch","validationCode":"# ensure no directory occupies the .gitattributes path in the module source\nls -la $(grep -q source dagger.json && echo source/ || echo .)/.gitattributes","typeGuard":null,"tryCatchPattern":"res, err := s.runCodegen(ctx, srcInst)\nif err != nil && strings.Contains(err.Error(), \"failed to add vcs generated file\") {\n    return fmt.Errorf(\"check .gitattributes path conflicts / engine storage: %w\", err)\n}","preventionTips":["Don't create a directory named .gitattributes inside the module source subpath.","For custom SDKs, return clean relative VCSGeneratedPaths entries.","Restart the engine if directory-mutation errors appear transiently."],"tags":["dagger","git","codegen","dagql"],"backgroundTag":"gitattributes-write-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"}