Closed
Conversation
Comment on lines
1095
to
1101
| app_compose = json.loads(compose_file_content) | ||
| except json.JSONDecodeError: | ||
| app_compose = {} | ||
| compose_changed = False | ||
| allowed_envs = list(envs.keys()) | ||
| if app_compose.get("allowed_envs") != allowed_envs: | ||
| app_compose["allowed_envs"] = allowed_envs | ||
| compose_changed = True | ||
| launch_token_value = envs.get("APP_LAUNCH_TOKEN") | ||
| if launch_token_value is not None: | ||
| launch_token_hash = hashlib.sha256( | ||
| launch_token_value.encode("utf-8") | ||
| ).hexdigest() | ||
| if app_compose.get("launch_token_hash") != launch_token_hash: | ||
| app_compose["launch_token_hash"] = launch_token_hash | ||
| compose_changed = True | ||
| compose_changed = apply_env_metadata_to_compose(app_compose, envs) | ||
| if compose_changed: | ||
| upgrade_params["compose_file"] = json.dumps( | ||
| app_compose, indent=4, ensure_ascii=False |
There was a problem hiding this comment.
Bug: When update_vm is called with both compose-modifying options and --env-file, the compose changes are overwritten and silently discarded due to re-loading stale data.
Severity: HIGH
Suggested Fix
The code path handling --env-file should not independently re-load the compose file from the server. Instead, it should operate on the potentially modified app_compose object from the preceding logic block to ensure that all updates are layered correctly before being finalized.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: vmm/src/vmm-cli.py#L1095-L1101
Potential issue: In the `update_vm` method, when a user provides both compose-modifying
options (e.g., `--compose`, `--prelaunch-script`) and an `--env-file` in the same
command, the changes from the compose-modifying options are silently discarded. This
occurs because the code path handling `--env-file` independently re-loads the original
compose file from the server, applies its own metadata, and then overwrites the
`upgrade_params["compose_file"]` variable, which may have already been updated by the
first code path. This results in the loss of the user's intended compose file
modifications.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
allowed_envsandlaunch_token_hashfrom encrypted env varscompose,deploy,update, andupdate-envso the APP_LAUNCH_TOKEN pattern works consistentlyValidation
python3 -m py_compile vmm/src/vmm-cli.pylaunch_token_hash