Repository navigation
Refuse to push an encrypted project that has no encryption key - #763
Conversation
A project pulled from an encrypted cloud project without a key keeps its ciphertext locally with `encrypted: true` and no `encryption-key-path`. Pushing it without flags uploaded the ciphertext as plain source and turned the cloud project's encryption off. The push now stops before changing anything and says to push with --encrypt --key or --decrypt --key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approving. The guard runs before any rename, create or update, and it only fires for an encrypted project that has neither a stored key nor --key. Projects with a stored key, unencrypted projects and pushes with --encrypt/--decrypt --key take the same path as before. The --push option of lean cloud backtest, optimize and live deploy goes through the same check. For such a project it now stops with a push error instead of sending ciphertext as plain source and turning off the cloud project's encryption. I checked that the new regression test fails on master and passes here.
I set risk:low. This is a small, easily reverted fix that replaces a destructive result with an error before anything changes. It has tests covering the refused push and both supported ways forward, green CI and an end-to-end run.
There was a problem hiding this comment.
Approving. I independently reproduced the failure on master and tested the fix end to end: refusing a keyless push preserves the cloud project's encryption state, key identity and files. Explicit encryption and decryption with a key both worked. All 212 cloud/encryption tests passed, and static analysis passed. I also verified that refusal precedes project creation or rename and does not stop a bulk push from processing the next project.
Description
lean cloud pullof an encrypted cloud project without a key writes the project's ciphertext locally, withencrypted: trueand noencryption-key-pathin its config. Runninglean cloud pushon that project without flags then uploaded the ciphertext as ordinary source and sent an empty encryption key, which turned the cloud project's encryption off. The cloud project ended up unencrypted, but its files were still ciphertext.PushManager._push_projectnow refuses to push a project whose config says it's encrypted when it has no key, either stored or given with--key. It stops before it renames, creates or updates anything, and reports:Both of those commands already worked for such a project.
--encrypt --keyuploads the ciphertext unchanged and keeps the cloud project encrypted with that key.--decrypt --keyuploads plaintext and turns encryption off on purpose. Projects with a stored key, unencrypted projects and pushes with flags are unchanged. As with other push errors, the project is skipped with a warning and any other projects in a push of all projects still go through.Testing
tests/commands/cloud/test_push.py, each starting with a keylesslean cloud pullof an encrypted cloud project:test_cloud_push_aborts_without_updating_cloud_project_when_project_pulled_encrypted_without_key: a push without flags doesn't create or update the cloud project. Fails onmaster, passes here.test_cloud_push_keeps_cloud_project_encrypted_when_project_pulled_encrypted_without_key_and_encrypted_flag_given:--encrypt --keysends the ciphertext and the key's hash.test_cloud_push_decrypts_cloud_project_when_project_pulled_encrypted_without_key_and_decrypted_flag_given:--decrypt --keysends plaintext and an empty key.python -m pytest -rs: 2902 passed, 81 skipped, 1 failed. The failure istests/ui/test_app.py::test_command_process_runs_the_cli_as_a_child_process, which also fails onmasterin my environment: the child process imports an installedlean 1.0.234instead of the checkout.python static_analysis.py: passed.master: the push reported success. The cloud project became unencrypted, and itsmain.pywas still the ciphertext.--encrypt --keysucceeded and the cloud project stayed encrypted with that key.--decrypt --keythen turned encryption off and uploaded plaintextmain.py.