Skip to content

Keep an in-project encryption key usable when push renames the project - #762

Merged
quantconnect-kronos[bot] merged 2 commits into
masterfrom
kronos/bug-742-renamed-project-key-path
Nov 20, 2026
Merged

quantconnect-kronos[bot] merged 2 commits into
masterfrom
kronos/bug-742-renamed-project-key-path

Conversation

@quantconnect-kronos

@quantconnect-kronos quantconnect-kronos Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #742

Description

When lean cloud push renames a project directory (its name is invalid locally, or the cloud returns a different name on creation), a key file stored inside the project moves with the directory, but the push kept using the old path, both from encryption-key-path and from an explicit --key. The push then failed with No such file or directory before uploading anything.

After the rename, PushManager._push_project now maps a key path inside the old project directory to the new one, and updates encryption-key-path in the project config. Keys outside the project directory keep their path, and pushes that don't rename are unchanged.

The mapping is ProjectManager.get_path_after_project_rename, next to rename_project_and_contents, so the other caller that renames projects can reuse it: lean cloud pull has the same problem, tracked in #761 and left out of this change.

The first commit is cherry-picked from #753 (author kept); the second moves its helper into ProjectManager and adds tests.

Testing

  • New tests, which fail on master and pass here:
    • test_cloud_push_follows_encryption_key_inside_project_when_push_renames_project (configured key)
    • test_cloud_push_follows_given_encryption_key_inside_project_when_push_renames_project (--encrypt --key)
  • New tests that pass on both: test_cloud_push_keeps_encryption_key_path_outside_project_when_push_renames_project, plus test_get_path_after_project_rename_* for paths inside and outside the project (including a sibling Old Project 2) and relative paths.
  • python -m pytest -rs: 2899 passed, 81 skipped, 1 failed. The failure is tests/ui/test_app.py::test_command_process_runs_the_cli_as_a_child_process, which fails the same way on master in my environment: the child process imported an installed lean 1.0.234 instead of the checkout.
  • python static_analysis.py: passed.
  • Tested end to end against a QuantConnect API. The project was encrypted with a registered key stored inside it, and the cloud returned a different name on creation:
    • master: the directory was renamed, then Cannot push '...': [Errno 2] No such file or directory: '<old dir>/key.txt', and the project's files were never uploaded.
    • This branch: the push succeeded. The cloud project is encrypted with that key, its main.py is the local ciphertext, and encryption-key-path names the renamed directory. A push with an explicit --encrypt --key inside the project also succeeded and left the cloud project encrypted with that key.

pcbeingused333 and others added 2 commits November 20, 2026 20:58
The remapping of a path inside a renamed project now lives next to
rename_project_and_contents, so every caller that renames a project can
reuse it. Covers an explicit --key inside the project and a configured
key outside the project, which keeps its path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving. When a push renames the project directory, a key inside it, whether set in encryption-key-path or given with --key, is now found at its new location. Keys outside the project keep their path. The two push tests for a key inside the project fail with master's push_manager.py and pass here. The pull side is left to #761.

I set risk:low: the change is small and easy to revert, the paths that work today behave as before, and it has tests that reproduce the failure, green CI and an end-to-end run.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk and removed kronos:review:working review: in progress labels Nov 20, 2026
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 20, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued and removed kronos:review Request review labels Nov 20, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress and removed kronos:review:queued review: queued labels Nov 20, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving. Independently tested end to end: a cloud-assigned rename preserves configured keys, explicit --encrypt --key and --decrypt --key, with the expected uploaded content and cloud encryption state. Outside-project keys remain usable. The three in-project cases fail on master with the old key path.

PYTHONPATH="$PWD" python -m pytest -q: 2900 passed, 81 skipped. Static analysis passed.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 20, 2026
@quantconnect-kronos
quantconnect-kronos Bot merged commit 3842533 into master Nov 20, 2026
60 checks passed
@quantconnect-kronos
quantconnect-kronos Bot deleted the kronos/bug-742-renamed-project-key-path branch November 20, 2026 21:46
@quantconnect-kronos quantconnect-kronos Bot removed the kronos:develop:working develop: in progress label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Low risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Push-induced rename leaves an in-project encryption key path pointing at the old directory

1 participant