{"record":{"id":"c8dc89a6cf3615eb","repo":"hasura/graphql-engine","slug":"error-in-writing-codegen-file-w","errorCode":null,"errorMessage":"error in writing codegen file: %w","messagePattern":"error in writing codegen file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadataobject/actions/actions.go","lineNumber":294,"sourceCode":"\t\tdata.CodegenConfig.URI = a.getActionsCodegenURI(data.CodegenConfig.Framework)\n\t}\n\n\tresp, err := a.cliExtensionConfig.GetActionsCodegen(data)\n\tif err != nil {\n\t\treturn errors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\"error in getting codegen for action %s: %w\", data.ActionName, err),\n\t\t)\n\t}\n\n\tfor _, file := range resp.Files {\n\t\terr = os.WriteFile(\n\t\t\tfilepath.Join(a.ActionConfig.Codegen.OutputDir, file.Name),\n\t\t\t[]byte(file.Content),\n\t\t\t0o644,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"error in writing codegen file: %w\", err))\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (a *ActionConfig) Validate() error {\n\treturn nil\n}\n\nfunc (a *ActionConfig) CreateFiles() error {\n\tvar (\n\t\top     errors.Op = \"actions.ActionConfig.CreateFiles\"\n\t\tcommon types.Common\n\t)\n\n\tdata, err := yaml.Marshal(common)\n\tif err != nil {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadataobject/actions/actions.go#L276-L312","documentation":"Codegen received generated files from the extension but failed writing them to ActionConfig.Codegen.OutputDir. Each file from resp.Files is written with os.WriteFile; any OS-level failure aborts with this error.","triggerScenarios":"Running actions codegen when the configured output directory (from actions.yaml codegen.output_dir) does not exist or is not writable; a generated file name collides with an existing directory.","commonSituations":"Default output dir (./src/generated/) never created; output_dir changed in actions.yaml to a path that doesn't exist; read-only workspace or container; generated file name like `types.ts` matching an existing directory name.","solutions":["Check the wrapped OS error, then create the output directory: mkdir -p <codegen.output_dir from actions.yaml>","Ensure the directory is writable by the current user","Verify no directory exists with the same name as a file the codegen writes","Re-run the codegen command"],"exampleFix":"# actions.yaml\n# before\ncodegen:\n  output_dir: src/generated/\n# after (create the dir, or point to an existing one)\nmkdir -p src/generated","handlingStrategy":"validation","validationCode":"outDir := cfg.ActionConfig.Codegen.OutputDir\nif err := os.MkdirAll(outDir, 0o755); err != nil {\n    return fmt.Errorf(\"cannot prepare codegen output dir: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Codegen(name, pld); err != nil {\n    if pe := new(fs.PathError); errors.As(err, &pe) {\n        _ = os.MkdirAll(cfg.ActionConfig.Codegen.OutputDir, 0o755)\n        // retry codegen once\n    }\n}","preventionTips":["Add codegen.output_dir creation to project bootstrap scripts","Point output_dir at an existing, committed directory","Ensure no directory shares a name with generated files"],"tags":["filesystem","codegen","actions","output-dir"],"backgroundTag":"file-write-permission-denied","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}