clawwork-ai / clawwork-ai/ClawWork
[Bug] migrateWorkspace path check uses hardcoded '/' separator, bypassed on Windows
- Dominant language
- TypeScript
- Stars
- 532
- Forks
- 75
- Avg merge
- 5h 31m
- Merged PRs (30d)
- 1
Description
## Problem
`migrateWorkspace` validates that the new workspace path is not inside the old one, to prevent a recursive copy loop. The check uses a hardcoded `/` separator, which is always wrong on Windows — `path.resolve()` returns `C:\foo\bar` style paths there, so `startsWith(oldPath + '/')` is always `false` and the guard is silently bypassed.
## Location
**File:** `packages/desktop/src/main/workspace/init.ts:11-17`
```typescript
export async function migrateWorkspace(oldPath: string, newPath: string): Promise {
if (!existsSync(oldPath)) throw new Error(`Source workspace does not exist: ${oldPath}`);
const resolvedOld = resolve(oldPath);
const resolvedNew = resolve(newPath);
if (resolvedNew.startsWith(resolvedOld + '/') || resolvedNew === resolvedOld) {
throw new Error('New workspace path must not be inside or equal to the current workspace');
}
```
On Windows, a user could pick `C:\workspace\sub` as the new workspace while the old one is `C:\workspace`, and the recursive copy would create `C:\workspace\sub\sub\sub\...` until disk fills up.
## Fix Approach
1. Import `sep` from `path`.
2. Replace `resolvedOld + '/'` with `resolvedOld + sep`.
## Verification
1. Run `pnpm check` — must pass.
2. Add a unit test for `migrateWorkspace` that exercises the nested-path rejection with platform-appropriate separators.
## Context
- **WG:** Artifact & File System
- **Priority:** Low (good first issue)
- **Estimated effort:** 10-15 minutes
Contributor guide
Research direction
Start in packages/desktop/src/main/workspace/init.ts:11-17 and inspect migrateWorkspace's resolved path guard. Import the platform separator and add a unit test covering rejection of a nested destination with platform-appropriate separators. Run pnpm check; done means the nested-path guard works on Windows without changing the existing error behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100