E2B icon indicating copy to clipboard operation
E2B copied to clipboard

fix(js-sdk): strip quotes from ENV values in fromDockerfile()

Open beran-t opened this issue 9 months ago • 3 comments

Summary

fromDockerfile() parses ENV instructions but stores values as raw strings without stripping quotes. This causes ENV GOPATH="/go" to produce "/go" (with literal quote characters) instead of /go.

Variable expansion (e.g. ${GOPATH}) is handled by the backend, so the SDK only needs to strip quotes.

Changes

  • Add stripQuotes() helper — removes surrounding " or ' from ENV values
  • Apply stripQuotes() to all value extraction points in handleEnvInstruction()
  • Add unit tests for quote stripping behavior

Before/After (tested)

Test Input Output
strips double quotes ENV GOPATH="/go" /go
strips single quotes ENV GOPATH='/go' /go
does not strip mismatched quotes ENV GOPATH="/go' "/go' (unchanged)
handles unquoted values ENV GOPATH=/go /go (unchanged)
preserves variable references as-is ENV PATH="/usr/bin:${GOPATH}/bin" /usr/bin:${GOPATH}/bin
strips quotes from multiple pairs ENV A="hello" B="world" hello, world
ARG with default value ARG MY_ARG="hello" hello
ARG without default ARG MY_ARG ""

Only packages/js-sdk/src/template/dockerfileParser.ts is modified (+97/-4 lines).

Test plan

  • [x] Unit tests for quote stripping (double, single, mismatched, unquoted, multi-pair)
  • [x] Integration build test: Dockerfile with ENV GOPATH="/go" + RUN test "$GOPATH" = "/go" — build succeeded, confirming quotes are stripped and backend expands variables
  • [x] Existing fromDockerfile.test.ts tests pass
  • [x] pnpm run format, pnpm run lint, pnpm run typecheck all pass

beran-t avatar Mar 03 '26 16:03 beran-t

⚠️ No Changeset found

Latest commit: 77c746cc718109a0a5e62596d0397392d518d535

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Mar 03 '26 16:03 changeset-bot[bot]

Package Artifacts

Built from 32c7d9a. Download artifacts from this workflow run.

JS SDK ([email protected]):

npm install ./e2b-2.14.2-fix-env-quote-stripping.0.tgz

CLI (@e2b/[email protected]):

npm install ./e2b-cli-2.8.1-fix-env-quote-stripping.0.tgz

Python SDK (e2b==2.15.1+fix-env-quote-stripping):

pip install ./e2b-2.15.1+fix.env.quote.stripping-py3-none-any.whl

github-actions[bot] avatar Mar 03 '26 16:03 github-actions[bot]

@claude does it need to be changed in Python as well?

mishushakov avatar Apr 16 '26 16:04 mishushakov