Repository navigation
Conversation
An envd call failure embeds the response body in the returned error and the init-failure log via envdErrorBody, capped at 100 runes. A volume-mount failure body carries the full chroot/bind path plus the errno text (~300 chars), so the 100-rune cut falls mid-path and strips the actual cause (no such file or directory, permission denied, ...), leaving an error that names a truncated path and nothing else. Raise envdErrorBodyRunes to 512 so the whole diagnostic survives. The body is still bounded: envdErrorBody reads through io.LimitReader(envdErrorBodyRunes* utf8.UTFMax+1) and Truncate still marks a longer body as cut, so the read-a-bounded-body protection is preserved - only the bound is larger. envd error bodies are short server-generated diagnostics, not arbitrary user data, so 512 carries no log-explosion risk. Rebased onto current main, which since the original attempt (e2b-dev#3481) refactored the four scattered utils.Truncate(string(body), 100) call sites into the single envdErrorBody helper; this changes only the cap constant. Existing tests updated to reference envdErrorBodyRunes instead of hard-coding 100, plus a case pinning that a ~300-char mount-failure body now survives intact. Fixes e2b-dev#3480. Supersedes e2b-dev#3481.
AdaAibaby
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
October 23, 2026 03:35
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased follow-up to #3481 (closed inactive). The problem is still present on
main; this is the current-structure fix plus the rationale for the value and for the approach chosen.Necessity — the failure cause lives only in the truncated body
On a failed envd
/init, the error returned to callers and theenvd init request failedlog both run the response body throughenvdErrorBody, capped at 100 runes. A volume-mount failure body looks like:That's ~300 chars, and the actual cause (
no such file or directory,permission denied, …) is at the end. The 100-rune cut lands mid-path, so the operator sees a truncated path and nothing about why it failed.Crucially, the cause is not available anywhere else:
X-Envd-Failed-Volumecarries only the path, whichVolumeMountErrorwraps asfailed to mount volume at %q— no errno.Capping at 100 therefore throws away the one piece of information needed to diagnose the failure.
Fix
Raise
envdErrorBodyRunesfrom 100 to 512. One constant; the read bound (envdErrorBodyRunes*utf8.UTFMax+1, viaio.LimitReader) scales with it, so the bounded-read protection is preserved — only the bound is larger (≈2 KiB, still nowhere near reading an unbounded body). envd error bodies are short server-generated diagnostics, so 512 carries no log-explosion risk, and ~300–450-char worst-case mount paths fit with margin.Approach considered and rejected — head+tail (tail-preserving) truncation
Since the cause sits at the tail of a Go error chain, a head+tail elision (keep the start and the end, drop the middle) would preserve the cause at any length and would be the theoretically more robust fix. It is not viable here:
TestEnvdCallsReadABoundedBodyexplicitly asserts (the client must not drain a 64 MiB body);…), and churn across the existing test expectations — for marginal gain over a 512-rune head cap that already covers the real worst case.So the right trade-off is the larger head cap: it keeps the existing format and the bounded-read guarantee, and fixes the actual diagnostic loss with a one-constant change.
Tests
envd_error_body_test.goupdated to referenceenvdErrorBodyRunesinstead of hard-coding100, so it tracks the cap;go build ./...,go vet, and the envd error-body suite pass.Fixes #3480. Supersedes #3481.