Skip to content

fix(execd): expand env before file read/stat#726

Merged
ninan-nn merged 2 commits intoalibaba:mainfrom
Pangjiping:hotfix/execd/expand-env
Apr 16, 2026
Merged

fix(execd): expand env before file read/stat#726
ninan-nn merged 2 commits intoalibaba:mainfrom
Pangjiping:hotfix/execd/expand-env

Conversation

@Pangjiping
Copy link
Copy Markdown
Collaborator

@Pangjiping Pangjiping commented Apr 16, 2026

Summary

  • expand env before file read/stat
  • resolved issue which execd cannot process file like $HOME/abc, ~/abc or $MY_WORKSPACE/abc
  • closes BUG: cannot read $HOME/file #711

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

@Pangjiping Pangjiping added the bug Something isn't working label Apr 16, 2026
@Pangjiping Pangjiping requested a review from hittyt as a code owner April 16, 2026 02:20
@Pangjiping Pangjiping requested a review from ninan-nn as a code owner April 16, 2026 02:20
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad2696700c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread components/execd/pkg/util/pathutil/path.go Outdated
@ninan-nn
Copy link
Copy Markdown
Collaborator

Question: should cwd expansion also consider request.Envs?

Right now cwd is expanded before cmd.Env is built, and pathutil.ExpandPath only reads the execd process env. So a request like this will fail if WORKDIR is not set on execd, even though the command itself would receive it via envs:

{
  "command": "pwd",
  "cwd": "$WORKDIR",
  "envs": {
    "WORKDIR": "/tmp/ws"
  }
}

Is this intended, or should cwd be expanded using the same effective env as the command?

@Pangjiping
Copy link
Copy Markdown
Collaborator Author

Pangjiping commented Apr 16, 2026

Question: should cwd expansion also consider request.Envs?

Right now cwd is expanded before cmd.Env is built, and pathutil.ExpandPath only reads the execd process env. So a request like this will fail if WORKDIR is not set on execd, even though the command itself would receive it via envs:

{
  "command": "pwd",
  "cwd": "$WORKDIR",
  "envs": {
    "WORKDIR": "/tmp/ws"
  }
}

Is this intended, or should cwd be expanded using the same effective env as the command?

Good idea. It is an excellent addition.

Considering the scope of the command request, we should support expanding paths from request.env, and I’ve already implemented this in the latest commit. bb7cd3e

Copy link
Copy Markdown
Collaborator

@ninan-nn ninan-nn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ninan-nn ninan-nn merged commit 915f172 into alibaba:main Apr 16, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component/execd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: cannot read $HOME/file

2 participants