{"record":{"id":"3d0bfa214effe25e","repo":"pulumi/pulumi","slug":"w-w","errorCode":null,"errorMessage":"%w: %w","messagePattern":"%w: %w","errorType":"exception","errorClass":"fs.ErrNotExist","httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/neo/acp/fs.go","lineNumber":101,"sourceCode":"\n// ReadTextFile fetches the full content of an absolute path from the editor via\n// the ACP `fs/read_text_file` request. Its signature matches\n// tools.Filesystem.ReadFileOverride, so it can be assigned to that field\n// directly, and it honors that field's contract of reporting missing files\n// with an error satisfying errors.Is(err, fs.ErrNotExist).\nfunc (c *ClientFS) ReadTextFile(ctx context.Context, path string) (string, error) {\n\tvar res readTextFileResult\n\tif err := c.Caller.Call(ctx, \"fs/read_text_file\", readTextFileParams{\n\t\tSessionID: c.SessionID,\n\t\tPath:      path,\n\t}, &res); err != nil {\n\t\t// ACP doesn't standardize a \"file not found\" error code, but the\n\t\t// ReadFileOverride contract requires missing files to surface as\n\t\t// fs.ErrNotExist (the edit tool's creation mode depends on it). The\n\t\t// editor's view is local disk plus its open buffers, so when the editor\n\t\t// couldn't read the file and it isn't on disk either, it doesn't exist.\n\t\tif _, statErr := os.Stat(path); errors.Is(statErr, fs.ErrNotExist) {\n\t\t\treturn \"\", fmt.Errorf(\"%w: %w\", fs.ErrNotExist, err)\n\t\t}\n\t\treturn \"\", err\n\t}\n\treturn res.Content, nil\n}\n","sourceCodeStart":83,"sourceCodeEnd":107,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/neo/acp/fs.go#L83-L107","documentation":"In the ACP filesystem ReadFileOverride path (pkg/cmd/pulumi/neo/acp/fs.go:101), when the editor-side read fails and the file also does not exist on local disk, the original editor error is wrapped with fs.ErrNotExist so callers see a standard not-found error. This satisfies the contract that missing files surface as errors.Is(err, fs.ErrNotExist), which the edit tool's creation mode depends on.","triggerScenarios":"The edit tool attempts to read a file via the editor override, the editor reports failure, and os.Stat(path) confirms the file is absent — the returned error then wraps fs.ErrNotExist.","commonSituations":"Creating a brand-new file with the edit tool (expected path — creation mode relies on ErrNotExist), typos in file paths, or files deleted on disk but still shown open in the editor.","solutions":["If creating a new file, this error is expected: proceed with the edit tool's creation mode, which checks for fs.ErrNotExist.","Verify the path is correct and relative to the session's working directory; list the directory to confirm the intended file location.","If the file should exist, refresh the editor's open buffers/revert unsaved state and retry — a stale buffer path can mask an on-disk rename or delete.","Re-run the operation after the file is restored or the path corrected."],"exampleFix":"// caller-side handling\ncontent, err := readFile(path)\nif errors.Is(err, fs.ErrNotExist) {\n    // create the file instead of editing\n    return createFile(path, newContent)\n}","handlingStrategy":"type-guard","validationCode":"if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {\n    // file missing before the call: use edit-tool creation mode\n}","typeGuard":"func isFileNotFound(err error) bool { return errors.Is(err, fs.ErrNotExist) }","tryCatchPattern":"content, err := reader.ReadFile(ctx, path)\nif errors.Is(err, fs.ErrNotExist) {\n    return createFile(path, defaultContent)\n}\nif err != nil { return err }","preventionTips":["Confirm the path exists (or intentionally use creation mode) before editing","Keep editor buffers in sync with disk; refresh after external renames/deletes","Always match with errors.Is(err, fs.ErrNotExist), not string comparison"],"tags":["filesystem","acp","file-not-found","edit-tool"],"backgroundTag":"file-not-found","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}