Repository navigation
Conversation
Failure-Class: none Re-verify BasedHardware#11758: no open PR; broken print(True) vs "true" reuse extract is absent on current main because cloud Agent VM deploy steps were removed in BasedHardware#11795. Restore resolve_agent_vm_sha_release.py for the regression suite and add a behavioral shell-contract test that runs the workflow one-liners against resolver output (broken path skips reuse branch; json.dumps and workflow_json_field_for_shell.py take it). Ratchet desktop-backend release policy against the Python-repr anti-pattern. Verification: backend/.venv/bin/python -m pytest tests/unit/test_resolve_agent_vm_sha_release.py -v python3 .github/scripts/check-desktop-backend-release-policy.py python3 .github/scripts/test_check_desktop_backend_release_policy.py Co-authored-by: Apoorv Darshan <[email protected]>
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 3/5
- In
.github/scripts/check-desktop-backend-release-policy.py, equivalent shell syntax such asif [[ "${reuse}" == "true" ]]can bypass the guard, causing PythonTrueto select the rebuild branch and potentially misapply the release policy; validatereuseextraction directly or support the shell comparison form.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/scripts/check-desktop-backend-release-policy.py">
<violation number="1" location=".github/scripts/check-desktop-backend-release-policy.py:190">
P2: Equivalent shell syntax such as `if [[ "${reuse}" == "true" ]]` bypasses this guard, allowing Python `True` to select the rebuild branch. Validate the resolver's `reuse` extraction directly or match the shell comparison semantically rather than requiring one literal spelling.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| f"{workflow}: Agent VM SHA reuse guard must not print a JSON boolean with Python repr " | ||
| '(use json.dumps or .github/scripts/workflow_json_field_for_shell.py)' | ||
| ) | ||
| if 'if [[ "$reuse" == "true" ]]' in text and "resolve_agent_vm_sha_release.py" in text: |
There was a problem hiding this comment.
P2: Equivalent shell syntax such as if [[ "${reuse}" == "true" ]] bypasses this guard, allowing Python True to select the rebuild branch. Validate the resolver's reuse extraction directly or match the shell comparison semantically rather than requiring one literal spelling.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/scripts/check-desktop-backend-release-policy.py, line 190:
<comment>Equivalent shell syntax such as `if [[ "${reuse}" == "true" ]]` bypasses this guard, allowing Python `True` to select the rebuild branch. Validate the resolver's `reuse` extraction directly or match the shell comparison semantically rather than requiring one literal spelling.</comment>
<file context>
@@ -181,6 +181,22 @@ def validate_deploy_workflow(text: str, *, production: bool) -> list[str]:
+ f"{workflow}: Agent VM SHA reuse guard must not print a JSON boolean with Python repr "
+ '(use json.dumps or .github/scripts/workflow_json_field_for_shell.py)'
+ )
+ if 'if [[ "$reuse" == "true" ]]' in text and "resolve_agent_vm_sha_release.py" in text:
+ shell_safe_reuse = (
+ 'json.dumps(json.load(open(sys.argv[1], encoding="utf-8"))["reuse"])',
</file context>
There was a problem hiding this comment.
Addressed in bda4509: the release-policy guard now matches ${reuse} / $reuse compares to JSON true semantically and requires shell-safe extraction in the same Agent VM resolver step (json.dumps or workflow_json_field_for_shell.py).
Failure-Class: none
- Fail closed when GCS describe errors are not object-not-found.
- Scope reuse-extract policy to resolver step blocks; match ${reuse} compares.
- Harden workflow_json_field_for_shell (with-open, scalar-only values).
- shlex.quote plan paths in shell contract test; add policy positive paths.
Verification:
PYTHONPATH=backend python3 -m pytest backend/tests/unit/test_resolve_agent_vm_sha_release.py -v
python3 .github/scripts/check-desktop-backend-release-policy.py
python3 .github/scripts/test_check_desktop_backend_release_policy.py
Co-authored-by: Apoorv Darshan <[email protected]>
|
Verified locally at bda4509 — good investigation on #11758, and the guard is genuinely behavioral. What I checked, file by file:
All 9 resolver tests, the policy checker, and the 36 policy-fixture tests pass in a worktree at this head; CI is green. One small wiring note (non-blocking): Since this extends the desktop-backend release-policy guard, it needs maintainer sign-off before merge per the repo's release-pipeline risk rule — leaving for human maintainer review for that sign-off, not for any code concern. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
fix(ci): real bug (broken Python-repr JSON boolean vs shell comparison), fixes #11758, confirmed NOT already fixed on main (resolve_agent_vm_sha_release.py doesn't exist there). Behavioral regression test proves broken-vs-fixed. CI green, candidate-clean-pr label. Confidence 4/5 (only the line-count criterion misses). Merging.
Fixes #11758
Investigation
Truetotrue, so every same-SHA redeploy failscmp#11758.main(bc37c8a76a), neither.github/workflows/desktop_backend_auto_dev.ymlnor.github/workflows/desktop_backend_prod.ymlcontains thereuse="$(python3 -c '…print(json.load…["reuse"])…')"snippet. Cloud Agent VM deploy steps were removed in Retire the cloud Agent VM: tombstone the broker endpoints, delete the control plane #11795; the bug existed on4f8da45f8747(issue evidence) through that retirement.print()on a JSON boolean emits PythonTrue, which never matches[[ "$reuse" == "true" ]].Fix
.github/scripts/workflow_json_field_for_shell.pyto emit JSON fields withjson.dumpsfor shell comparisons.backend/scripts/resolve_agent_vm_sha_release.pyand extendbackend/tests/unit/test_resolve_agent_vm_sha_release.pywith a behavioral regression that runs the workflow one-liners in bash against resolver-shaped output:print(json.load…["reuse"])→ rebuild branchprint(json.dumps(json.load…["reuse"]))and the helper → reuse branchcheck-desktop-backend-release-policy.pyto reject the Python-repr reuse extract when Agent VM resolver steps are present.If Agent VM deploy steps are restored, both desktop-backend workflows must use one of:
reuse="$(python3 -c 'import json,sys; print(json.dumps(json.load(open(sys.argv[1], encoding="utf-8"))["reuse"]))' "$RUNNER_TEMP/agent-vm-sha-release.json")"or:
reuse="$(python3 .github/scripts/workflow_json_field_for_shell.py "$RUNNER_TEMP/agent-vm-sha-release.json" reuse)"Verification
All passed locally (8 pytest cases; 32 policy unittest cases).
Failure-Class: none