Skip to content

fix: keep sanitized project paths inside the workspace - #789

Open
pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:fix/empty-sanitized-path-component
Open

pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:fix/empty-sanitized-path-component

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #776

Root cause: _format_local_path replaces forbidden characters with spaces, then strips spaces and trailing periods from each component, so a component such as :, or .. could become empty. For :/Strategy the result was /Strategy; joining that to Path.cwd() discards the workspace, and cloud push then raised ValueError from relative_to. A name that sanitized to nothing entirely resolved to the workspace directory itself.

Fix: a component that sanitizes to an empty string is named _, so :/Strategy becomes _/Strategy (the issue allows a usable local name or a validation error; this takes the first). Empty components from leading, trailing or repeated separators are skipped, which also keeps a leading / from making the path absolute.

Tests: a parametrized test for get_local_project_path covers these names; five of its six cases fail before the change (the trailing separator case guards existing behaviour). tests/components/util, tests/components/cloud and tests/commands/cloud pass. The reproduction from the issue, followed by rename_project_and_contents, now moves the project to _/Strategy inside the workspace.

This change was prepared with AI assistance.

A path component made only of forbidden characters, spaces or periods sanitized to an empty string. As the first component that made the local path absolute, so cloud push failed with ValueError. Name such components "_" and skip empty components between separators.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

An empty sanitized parent component gives cloud push a destination outside the workspace

1 participant