feat(apps): support absolute and relative upload paths#2005
Conversation
📝 WalkthroughWalkthroughLocal input paths now use platform-aware validation and shared typed-error file helpers. Apps file upload adopts these helpers for validation and reading, with expanded unit, integration, dry-run, live workflow, and coverage documentation tests. ChangesLocal file input and upload
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant RuntimeContext
participant LocalInputPath
participant LocalFilesystem
participant UploadAPI
CLI->>RuntimeContext: ValidateLocalFileFlag("--file", maxBytes)
RuntimeContext->>LocalInputPath: Validate path
LocalInputPath-->>RuntimeContext: Validated path
RuntimeContext->>LocalFilesystem: Stat regular file and size
RuntimeContext-->>CLI: Validation result
CLI->>RuntimeContext: ReadLocalFileFlag("--file", maxBytes)
RuntimeContext->>LocalFilesystem: Open and bounded read
LocalFilesystem-->>RuntimeContext: File bytes
RuntimeContext-->>CLI: File bytes
CLI->>UploadAPI: Upload file bytes
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@8ece7c0c16c2abf486a0f8577300885ee3202c04🧩 Skill updatenpx skills add larksuite/cli#agent/apps-file-upload-local-paths -y -g |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/vfs/localfileio/path.go`:
- Around line 58-59: Update the test covering the SafeInputPath validation in
the relevant path-parsing flow to assert that the returned error unwraps to the
original validation error, not only that its message matches. Capture the
underlying error from SafeInputPath and verify errors.Is or equivalent
unwrapping against the returned error, preserving the existing text assertion if
useful.
In `@tests/cli_e2e/apps/apps_file_upload_dryrun_test.go`:
- Around line 60-61: Update the assertions in the file-upload dry-run test to
parse the validation envelope from result.Stdout instead of result.Stderr. If
the command implementation currently writes this structured validation JSON to
stderr, change its output routing so JSON program output uses stdout while
progress, warnings, and hints remain on stderr.
In `@tests/cli_e2e/apps/apps_file_upload_live_test.go`:
- Around line 21-28: Update TestAppsFileUploadLiveWorkflow to remove the
LARKSUITE_CLI_CONFIG_DIR requirement and skip gate. Keep the dedicated
LARK_CLI_E2E_APPS_FILE_APP_ID fixture check, and use the repository’s live-token
skip helper for credential validation instead of requiring config isolation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4c19e0f7-c480-407c-8f94-9ddc6b040f74
📒 Files selected for processing (16)
internal/cmdutil/localfile.gointernal/cmdutil/localfile_test.gointernal/validate/path.gointernal/validate/path_test.gointernal/vfs/localfileio/path.gointernal/vfs/localfileio/path_local_other.gointernal/vfs/localfileio/path_local_windows.gointernal/vfs/localfileio/path_local_windows_test.gointernal/vfs/localfileio/path_test.goshortcuts/apps/apps_file_upload.goshortcuts/apps/apps_file_upload_test.goshortcuts/common/localfile.goshortcuts/common/localfile_test.gotests/cli_e2e/apps/apps_file_upload_dryrun_test.gotests/cli_e2e/apps/apps_file_upload_live_test.gotests/cli_e2e/apps/coverage.md
Summary
Allow
apps +file-upload --fileto read absolute and parent-relative local paths without weakening the existing workspace-confinedFileIObehavior used by other commands.Changes
internal/.RuntimeContext.ValidateLocalFileFlagandReadLocalFileFlaghelpers for gradual shortcut adoption.apps +file-uploadto the shared helper.Test Plan
go test ./shortcuts/common ./shortcuts/appsgo test -race ./shortcuts/common ./shortcuts/appsgo vet ./internal/cmdutil ./internal/validate ./internal/vfs/localfileio ./shortcuts/common ./shortcuts/appsgolangci-lint run --new-from-rev=origin/mainfor the affected packagesRelated Issues
Summary by CodeRabbit
New Features
Bug Fixes
Documentation