[PR #30710] fix(i18n): resolve Claude Code sandbox path issues in workflow #32938

Closed
opened 2026-02-21 20:52:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30710

State: closed
Merged: Yes


Summary

Follow-up fix for #30692. Resolves issues discovered during workflow execution when Claude Code sandbox working directory may vary.

Issues Fixed

1. Command Substitution Not Supported

Problem: git checkout -b "chore/i18n-sync-$(date +%Y%m%d-%H%M%S)" fails because Claude Code's Bash tool doesn't support $() command substitution.

Fix: Split into two separate commands:

# First, get timestamp
date +%Y%m%d-%H%M%S
# → 20260115-143052

# Then create branch using the output
git -C ${{ github.workspace }} checkout -b chore/i18n-sync-20260115-143052

2. Working Directory Path Resolution

Problem: Claude Code sandbox working directory may vary (could be repo root or web/ subdirectory). Relative paths like git add web/i18n/ or pnpm --dir web may fail depending on the actual working directory.

Fix: Use absolute paths for ALL commands to ensure reliability regardless of working directory:

  • pnpm --dir ${{ github.workspace }}/web <command>
  • git -C ${{ github.workspace }} <command>
  • gh --repo ${{ github.repository }} <command>
  • File paths: ${{ github.workspace }}/web/i18n/...

3. Missing Tool Permission

Problem: date command needed for timestamp but not in allowedTools.

Fix: Added Bash(date *),Bash(date:*) to allowedTools.

Changes

Category Before After
pnpm commands pnpm --dir web install pnpm --dir ${{ github.workspace }}/web install
git commands git add web/i18n/ git -C ${{ github.workspace }} add web/i18n/
gh commands gh pr create gh pr create --repo ${{ github.repository }}
File paths web/i18n-config/languages.ts ${{ github.workspace }}/web/i18n-config/languages.ts
Branch creation $(date +%Y%m%d) substitution Two separate commands
allowedTools 10 patterns 12 patterns (+date)

Best Practices Applied

  1. Always use absolute paths - Claude Code sandbox working directory is not guaranteed
  2. Never use command substitution - $() is not supported in Claude Code's Bash tool
  3. Run commands one by one - Don't combine with && or ||
  4. Document clearly - Added "WORKING DIRECTORY & ABSOLUTE PATHS" section in prompt

Test Plan

  • Trigger workflow manually with workflow_dispatch
  • Verify pnpm commands work with absolute paths
  • Verify git commands use correct absolute paths
  • Verify branch creation works with two-step approach
  • Verify PR creation succeeds

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/langgenius/dify/pull/30710 **State:** closed **Merged:** Yes --- ## Summary Follow-up fix for #30692. Resolves issues discovered during workflow execution when Claude Code sandbox working directory may vary. ## Issues Fixed ### 1. Command Substitution Not Supported **Problem**: `git checkout -b "chore/i18n-sync-$(date +%Y%m%d-%H%M%S)"` fails because Claude Code's Bash tool doesn't support `$()` command substitution. **Fix**: Split into two separate commands: ```bash # First, get timestamp date +%Y%m%d-%H%M%S # → 20260115-143052 # Then create branch using the output git -C ${{ github.workspace }} checkout -b chore/i18n-sync-20260115-143052 ``` ### 2. Working Directory Path Resolution **Problem**: Claude Code sandbox working directory may vary (could be repo root or `web/` subdirectory). Relative paths like `git add web/i18n/` or `pnpm --dir web` may fail depending on the actual working directory. **Fix**: Use absolute paths for ALL commands to ensure reliability regardless of working directory: - `pnpm --dir ${{ github.workspace }}/web <command>` - `git -C ${{ github.workspace }} <command>` - `gh --repo ${{ github.repository }} <command>` - File paths: `${{ github.workspace }}/web/i18n/...` ### 3. Missing Tool Permission **Problem**: `date` command needed for timestamp but not in allowedTools. **Fix**: Added `Bash(date *),Bash(date:*)` to allowedTools. ## Changes | Category | Before | After | |----------|--------|-------| | pnpm commands | `pnpm --dir web install` | `pnpm --dir ${{ github.workspace }}/web install` | | git commands | `git add web/i18n/` | `git -C ${{ github.workspace }} add web/i18n/` | | gh commands | `gh pr create` | `gh pr create --repo ${{ github.repository }}` | | File paths | `web/i18n-config/languages.ts` | `${{ github.workspace }}/web/i18n-config/languages.ts` | | Branch creation | `$(date +%Y%m%d)` substitution | Two separate commands | | allowedTools | 10 patterns | 12 patterns (+date) | ## Best Practices Applied 1. **Always use absolute paths** - Claude Code sandbox working directory is not guaranteed 2. **Never use command substitution** - `$()` is not supported in Claude Code's Bash tool 3. **Run commands one by one** - Don't combine with `&&` or `||` 4. **Document clearly** - Added "WORKING DIRECTORY & ABSOLUTE PATHS" section in prompt ## Test Plan - [ ] Trigger workflow manually with `workflow_dispatch` - [ ] Verify pnpm commands work with absolute paths - [ ] Verify git commands use correct absolute paths - [ ] Verify branch creation works with two-step approach - [ ] Verify PR creation succeeds 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-21 20:52:21 -05:00
yindo closed this issue 2026-02-21 20:52:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32938