{"record":{"id":"a06d0c0bf35cc7b4","repo":"pulumi/pulumi","slug":"reading-environment-definition-w","errorCode":null,"errorMessage":"reading environment definition: %w","messagePattern":"reading environment definition: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/esc/cli/env_edit.go","lineNumber":86,"sourceCode":"\t\t\tref, args, err := edit.env.getExistingEnvRef(ctx, args)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif ref.version != \"\" {\n\t\t\t\treturn errors.New(\"the edit command does not accept versions\")\n\t\t\t}\n\t\t\t_ = args\n\n\t\t\tif file != \"\" {\n\t\t\t\tvar yaml []byte\n\t\t\t\tswitch file {\n\t\t\t\tcase \"-\":\n\t\t\t\t\tyaml, err = io.ReadAll(env.esc.stdin)\n\t\t\t\tdefault:\n\t\t\t\t\tyaml, err = fs.ReadFile(env.esc.fs, file)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"reading environment definition: %w\", err)\n\t\t\t\t}\n\n\t\t\t\tdiags, err := edit.env.esc.updateEnvironment(ctx, ref, draft, yaml, \"\", \"Environment updated.\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tif len(diags) != 0 {\n\t\t\t\t\terr = edit.env.writeYAMLEnvironmentDiagnostics(\n\t\t\t\t\t\tedit.env.esc.stderr,\n\t\t\t\t\t\tref.projectName+\"/\"+ref.envName,\n\t\t\t\t\t\tyaml,\n\t\t\t\t\t\tdiags,\n\t\t\t\t\t)\n\t\t\t\t\tcontract.IgnoreError(err)\n\t\t\t\t}\n\t\t\t\tif client.DiagnosticsHaveErrors(diags) {\n\t\t\t\t\treturn err","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/esc/cli/env_edit.go#L68-L104","documentation":"When `esc env edit --file` is given a file ('-' for stdin or a filesystem path), this wraps any error from reading that file's YAML bytes. It indicates the environment definition could not be loaded before being validated/applied.","triggerScenarios":"Running `esc env edit --file config.yaml` where config.yaml does not exist, is unreadable (permissions), or stdin ('-') fails/closes; also `esc env edit - < missing-input`.","commonSituations":"Typo in the filename or wrong working directory; file created by a prior pipeline step that failed; redirecting stdin in a script where the producer failed; permission-restricted files.","solutions":["Check the file path is correct relative to the current directory","Verify read permissions on the file (ls -l, chmod if needed)","If using '-', ensure stdin actually contains the YAML (check the upstream command/redirect)","Read the wrapped cause (%w) — for fs.PathError it names the exact path and reason"],"exampleFix":"// before\nesc env edit --file enviroment.yaml   # typo\n// after\nesc env edit --file environment.yaml","handlingStrategy":"try-catch","validationCode":"if file != \"\" && file != \"-\" {\n    if _, err := os.Stat(file); err != nil {\n        return fmt.Errorf(\"file %q not readable: %w\", file, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"yaml, err := fs.ReadFile(env.esc.fs, file)\nif err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        return fmt.Errorf(\"cannot read %s: %v\", perr.Path, perr.Err)\n    }\n    return fmt.Errorf(\"reading environment definition: %w\", err)\n}","preventionTips":["Verify the --file path with ls before running","Check read permissions on the YAML file","When using '-', confirm the upstream producer actually wrote to stdin","Run from the directory you expect — paths are resolved relative to the CLI's filesystem"],"tags":["cli","esc","file-io","yaml"],"backgroundTag":"file-read-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}