Skip to content

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

Open
beran-t wants to merge 4 commits intomainfrom
fix-env-quote-stripping
Open

fix(js-sdk): strip quotes from ENV values in fromDockerfile()#1176
beran-t wants to merge 4 commits intomainfrom
fix-env-quote-stripping

Conversation

@beran-t
Copy link
Contributor

@beran-t beran-t commented Mar 3, 2026

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

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

The Dockerfile parser stored ENV values as raw strings without stripping
surrounding quotes. This caused ENV GOPATH="/go" to produce "/go"
(with literal quote characters) instead of /go.

Add a stripQuotes() helper and apply it to all value extraction points
in handleEnvInstruction(). Variable expansion is handled by the backend.
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 77c746c

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Package Artifacts

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

JS SDK (e2b@2.14.2-fix-env-quote-stripping.0):

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

CLI (@e2b/cli@2.8.1-fix-env-quote-stripping.0):

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

@ValentaTomas ValentaTomas removed their request for review March 12, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants