envd: distinguish expected stdin lifecycle errors from CodeInternal
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.6k
- Forks
- 438
- PR merge metrics
- No merged PRs in 30d
Description
Problem
Process.SendInput currently maps every Handler.WriteStdin failure to
CodeInternal.
Some of these failures are expected process lifecycle outcomes:
- stdin is disabled or already closed;
- a PTY process receives stdin input;
- the process exits and its stdin pipe returns EPIPE/file-already-closed.
CodeInternal is reserved for serious invariant failures, so clients cannot
distinguish a normal process-state transition from an unexpected envd failure.
This also races with the Start response stream: SendInput can return
CodeInternal before the process's EndEvent arrives on the independent stream.
Proposed semantics
- process selector no longer exists: CodeNotFound
- process exists but cannot accept stdin: CodeFailedPrecondition
- unexpected underlying I/O failure: CodeInternal
CloseStdin should follow the same error taxonomy.
The EndEvent remains authoritative for exit status; a SendInput error alone
must not be treated as the terminal process result.
Compatibility
This changes observable Connect error codes, although callers that only check
for a non-nil error are unaffected. Python and JavaScript SDK behavior should
be checked before merging.
Reproduction
Start a short-lived non-PTY process, wait for its stdin pipe to close, then
call SendInput before the delayed EndEvent is delivered. The current service
returns CodeInternal for the closed pipe.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Process.SendInput, Handler.WriteStdin, and CloseStdin, then trace how Connect exposes their errors and how the independent EndEvent stream reports termination. Check the Python and JavaScript SDK handling of these errors. Done means nonexistent selectors produce CodeNotFound, unavailable stdin produces CodeFailedPrecondition, unexpected I/O remains CodeInternal, and EndEvent remains authoritative.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, javascript, python
- Domain
- api, backend, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100