Skip to content

chore(tests): escape the shell backslash in the git stub heredoc - #13720

Merged
teamleaderleo merged 1 commit into
mainfrom
chore/python-invalid-escape
Sep 23, 2026
Merged

teamleaderleo merged 1 commit into
mainfrom
chore/python-invalid-escape

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Every guard job that imports tests/test_issue_1138_sidebar_pr_polling.py prints:

tests/test_issue_1138_sidebar_pr_polling.py:50: SyntaxWarning: invalid escape sequence '\ '

_git_stub() builds a /bin/sh script inside a normal (non-raw) Python string, and its case pattern escapes a space for the shell:

ref:\ refs/heads/*)

\ is not a Python escape sequence. Python leaves it as backslash-space, so the stub has always produced the right shell script — but the warning is real, and invalid escape sequences are slated to become a SyntaxError. The same string already writes \\n two lines further down, so this reads as an oversight rather than a deliberate choice.

Verified

Doubling the backslash produces the identical shell script:

  • rendered stub is byte-identical, sha256 90fc977171af3de3 before and after
  • the six bash scenarios pass (prompt_does_not_call_gh, merge_action, close_action_target, failed_merge_no_action, non_pr_gh_no_action, head_change_clears_pr), and the escaped-space case branch is on the path the branch-reading scenarios exercise
  • compile() on the file reports no SyntaxWarning afterwards

I could not run the zsh half locally — no zsh on this machine — so that side is covered by CI. Behaviour is unchanged regardless, since the generated script is byte-identical.

Sweeping every .py in the repository outside node_modules/ghostty/build, this is the only invalid escape sequence, so the log goes quiet with this one change.

A guard that fails the build on any new SyntaxWarning would keep it that way. I left it out here because it needs a tests/test-execution.toml entry and #13710/#13712 are both editing that file right now; worth adding once one of them lands.

Note on CI

guards / workflow-guard-tests / preflight is expected to fail on this PR for a reason unrelated to it: nine tests have reached main without an execution-registry entry, so validate_test_execution_registry.py exits 1 on any branch based on current main. #13710 fixes that.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes a SyntaxWarning on every import of tests/test_issue_1138_sidebar_pr_polling.py by doubling a backslash in the git stub heredoc. The generated shell script is byte-identical, so behavior is unchanged.

Written for commit 52ff9d4. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Clarified escaping in a regression test to prevent invalid escape-sequence warnings.
    • No user-facing behavior changes.

`_git_stub()` builds a `/bin/sh` script inside a normal (non-raw) Python
string, and its `case` pattern escapes a space for the shell:

    ref:\ refs/heads/*)

`\ ` is not a Python escape sequence. Python leaves it as backslash-space,
so the stub has always been correct, but it emits

    SyntaxWarning: invalid escape sequence '\ '

on every import, which shows up in the guard job logs, and invalid escape
sequences are slated to become a SyntaxError. The same string already
writes `\\n` two lines further down, so this is an inconsistency rather
than a deliberate choice.

Doubling the backslash produces the identical shell script: the rendered
stub hashes the same before and after (sha256 90fc977171af3de3), and the
six bash scenarios still pass. It is the only invalid escape sequence in
the repository's Python.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: fa534bd2-44d2-40b1-8c76-48eccb015113

📥 Commits

Reviewing files that changed from the base of the PR and between e09effe and 52ff9d4.

📒 Files selected for processing (1)
  • tests/test_issue_1138_sidebar_pr_polling.py

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The regression test now explicitly escapes the backslash-space sequence in its embedded git stub. The generated shell script behavior remains unchanged.

Changes

Test escape cleanup

Layer / File(s) Summary
Explicit shell escape
tests/test_issue_1138_sidebar_pr_polling.py
The HEAD case pattern uses a doubled backslash in the Python source. Both source forms generate the same shell pattern.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 52ff9

This test-only cleanup removes an import warning while preserving the generated shell stub’s behavior, so it is ready to merge.

🚥 Pre-merge checks | ✅ 24 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (24 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the change: escaping the shell backslash in the Git stub heredoc.
Description check ✅ Passed The description explains the warning, the cause, the exact fix, behavior preservation, and test results. It does not reproduce the template headings or checklist, but it provides the required summary …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Cloud Persistent Session And Early Input ✅ Passed PASS: The PR changes only the ref:\\\\ refs/heads/*) escape in a test shell stub. The governing rule applies to Cloud terminal creation, persistent transport, manual panes, and runtime admission. This…
Cmux Swift Actor Isolation ✅ Passed The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py. The diff contains no Swift files and no production code. The custom check excludes this test-only Python change.
Cmux Swift Blocking Runtime ✅ Passed PASS: The authoritative PR diff changes only tests/test_issue_1138_sidebar_pr_polling.py. It contains no Swift files and introduces no blocking or timing-based Swift synchronization. The change is d…
Cmux Browser Automation Off-Main ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, escaping a backslash in a shell-script test fixture. The diff contains no browser.* command, WebKit/AppKit access, …
Cmux Expensive Synchronous Load ✅ Passed The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py. The one-line change escapes a backslash in a Python shell-stub string. The diff contains no Swift changes and does not add …
Cmux Cache Substitution Correctness ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test helper. It does not change production Swift, TypeScript, or JavaScript code, and it does not substitute…
Cmux No Hacky Sleeps ✅ Passed PASS. The PR changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test helper. The one-line change escapes a backslash in the generated shell stub and does not introduce or expand any …
Cmux Algorithmic Complexity ✅ Passed PASS: The PR changes only tests/test_issue_1138_sidebar_pr_polling.py. The one-line change escapes a backslash in a Python test heredoc string. It does not change production Swift, TypeScript, JavaS…
Cmux Swift Concurrency ✅ Passed The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test file. The authoritative diff contains no Swift files or Swift concurrency changes. Therefore the cmux Swift c…
Cmux Swift @Concurrent ✅ Passed The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python file. The authoritative diff contains no Swift or Objective-C files, so the Swift @concurrent criteria do not ap…
Cmux Swift Package Boundaries ✅ Passed The reviewed range changes only tests/test_issue_1138_sidebar_pr_polling.py. It contains no Swift or Swift package changes, and the custom check does not apply.
Cmux Swiftpm Lockfiles ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py. It changes no SwiftPM package, Package.resolved, Xcode project, .gitignore, workflow, or dependency file. The Swi…
Cmux Swift Logging ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test fixture. It adds no Swift code and no logging statements. The Swift logging check is therefore not appl…
Cmux User-Facing Error Privacy ✅ Passed PASS. The PR changes only tests/test_issue_1138_sidebar_pr_polling.py, which is developer-only test code explicitly allowed by the rule. The changed _git_stub() string has the same evaluated bytes…
Cmux Full Internationalization ✅ Passed The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py. The one-line change escapes a shell backslash inside a test stub heredoc. It adds no user-facing text, localization key, ca…
Cmux Swiftui State Layout ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test file. It introduces no SwiftUI code, state, layout measurement, list row store reference, or render-tim…
Cmux Architecture Rethink ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, a Python test. The single change doubles a backslash in a shell heredoc pattern. It introduces no Swift architecture …
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PASS: The pull request changes only tests/test_issue_1138_sidebar_pr_polling.py, with a one-character Python string escape update. The authoritative diff contains no Swift files and no NSWindow, NSPan…
Cmux Source Artifacts ✅ Passed The PR changes only tests/test_issue_1138_sidebar_pr_polling.py. The diff is a one-line edit in a hand-written regression test and adds no local output, generated logs, cache, build artifact, scratc…
Cmux No Test Or Debug Seam In Production Source ✅ Passed PASS: The reviewed range changes only tests/test_issue_1138_sidebar_pr_polling.py. It contains no Swift file and no production Sources/ path, so it cannot introduce a test or debug seam in product…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@teamleaderleo
teamleaderleo merged commit f1cad33 into main Sep 23, 2026
36 of 38 checks passed
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.

1 participant