Skip to content

Studio Terminal: give the heredoc quote scanner its own substitution helper - #17442

Merged
danielhanchen merged 1 commit into
mainfrom
studio-tools-substitution-end-collision
Nov 10, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-tools-substitution-end-collision

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Source lint fails on main since #17256, and on every PR based on it (seen on #17429 and #17435):

duplicate definitions (1):
  studio/backend/core/inference/tools.py:9806: _substitution_end is defined twice (def at line 6738, def here)

These are not two copies of one function. They are two different helpers that ended up with the same name:

Added by Returns for $( ... ) Unterminated Quotes inside
line 6738 #17256 (heredoc screening), used by _quote_end one past the ) -1 _quote_end, which handles \" and nested $(
line 9806 #17010 (Windows 2>nul rewrite), used by _bash_nul_to_dev_null the index of the ) len(command) naive find of the same quote

The later definition wins at module scope. So since #17256 merged, its _quote_end has been running #17010's helper rather than the one written for it, while #17010's nul rewrite keeps its own. The lint is right, and both PRs are correct on their own. The fix is to give #17256's helper its own name.

The practical effect is small but real: the two disagree on some quoting. For example, "( )'$("")"` reads as unterminated with the intended helper and as closed with the shadowing one, which changes how the Terminal heredoc screen splits that command.

Change

Testing

  • scripts/lint_duplicate_definitions.py on tools.py: flags main, clean here
  • studio/backend/tests/test_permission_mode.py and test_windows_bash_nul_redirect.py: 2637 passed, 1 skipped. The new test fails on main.
  • tests/test_lint_duplicate_definitions.py: 12 passed

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T20:18:08.051815Z c56d74f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c56d74f0e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 322c4c1 into main Nov 10, 2026
@danielhanchen
danielhanchen deleted the studio-tools-substitution-end-collision branch November 10, 2026 20:23
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