[BUG] VS Code extension logs ENOENT when interpreter connections directory is absent
Describe the bug
Prompt Flow VS Code extension 1.20.2 logs an error on every activation when the active Python interpreter does not have a Prompt Flow connections directory:
Error: ENOENT: no such file or directory, scandir "$HOME/.promptflow/envs/<sha1-of-interpreter-path>/connections"
at async readdir
at async apt (.../prompt-flow.prompt-flow-1.20.2/extension.js:242:3754)
at async listConnectionSpecs (.../extension.js:34149:41876)The hash in my reproducer is exactly SHA-1 of the active interpreter path. It repeats independently in both restored VS Code windows.
Root cause in the shipped extension
The 1.20.2 bundle constructs the per-interpreter path, waits up to five seconds for it to exist, and then returns the path unconditionally. listConnectionSpecs passes that result to a helper that calls fs.promises.readdir; the helper catches the resulting ENOENT, reports it through the extension error logger, and returns an empty map. The observable behavior is therefore already “no custom connection specs,” but it emits an error first.
Expected behavior
An absent per-interpreter connections directory should produce an empty custom-spec set without an error. It should not require users to create SDK-owned directories manually.
Suggested fix
After the bounded wait, return the path only if it exists; otherwise return the empty path already handled by the reader. Alternatively, make the directory reader treat only ENOENT as an empty set while retaining errors for permission and parse failures.
Please cover:
- supported Prompt Flow version with no connections directory
- absent Prompt Flow SDK
- directory appearing during the bounded wait
- non-ENOENT filesystem and invalid JSON failures
Environment
- Prompt Flow extension 1.20.2
- VS Code 1.133.0
- macOS arm64
Source: microsoft/promptflow