Skip to content

FIX: Fix CodeChameleonConverter decryption functions in binary_tree and length modes - #3165

Merged
Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
RohithPariki:fix/codechameleon-decryption-functions
Oct 13, 2026
Merged

Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
RohithPariki:fix/codechameleon-decryption-functions

Conversation

@RohithPariki

@RohithPariki RohithPariki commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #3164. Incorporates the binary-tree fix previously proposed in #3072 and preserves its boundary regression coverage.

The generated CodeChameleonConverter decryption instructions contained two runtime failures:

  1. binary_tree: The initial json.loads(problem_description) already parses nested child dictionaries. Removing the redundant recursive json.loads calls avoids TypeError when a tree has children.
  2. length: The encoder emits a JSON string, but the decoder expected a list of dictionaries. The instructions now import json and parse string inputs before decoding, while continuing to accept already parsed lists.

No constructor, encryption format, or supported modality changes. Merged main through d3a04c8d7496e0cb4fa5a80df616132d1d9169ff before pushing.

Tests and Documentation

Updated the instruction snapshots and expanded the generated-code execution regression to 12 inputs across all four built-in modes. Coverage includes empty and whitespace-only inputs, single nodes, both child branches, nested odd/even trees, whitespace normalization, escaped values, repeated words, and Unicode. The length cases also exercise already parsed lists. The tests run the actual emitted decryption code against real converter output without provider calls.

Local validation on the pushed head:

  • uv run --no-sync pytest tests\unit\converter\test_code_chameleon_converter.py -q: 54 passed.
  • uv run --no-sync ruff check pyrit\converter\codechameleon_converter.py tests\unit\converter\test_code_chameleon_converter.py: passed.
  • uv run --no-sync ruff format --check pyrit\converter\codechameleon_converter.py tests\unit\converter\test_code_chameleon_converter.py: passed, both files already formatted.
  • uv run --no-sync ty check pyrit\converter\codechameleon_converter.py: passed.
  • Restoring the original main decoders in memory caused all four selected binary-tree/length regression cases to fail, confirming that the tests catch both original bugs.

All six source-head workflows passed on b17480428e36a7fb893ffb4cd3d9749b0e35ffb3, with all 36 required check contexts verified. One failed-job-only retry was needed for an unrelated two-second Copilot target test setup timeout on macOS/Python 3.11; the retry passed without unrelated code changes. Merge-queue integration checks are separate from these source-head results.

No documentation API or modality-table updates are needed for these instruction corrections.

JupyText was not run locally; no notebook or documentation source files changed.

@romanlutz

Copy link
Copy Markdown
Contributor

#3072 was technically here first but author didn't accept the CLA so happy to merge this.

@romanlutz Roman Lutz (romanlutz) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a couple of improvements and then merge. Thank you!

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40dcbc75-65c2-470f-8978-3b7f95ae03a7
Cover boundary inputs across all built-in modes and preserve length decoding of already parsed lists.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 40dcbc75-65c2-470f-8978-3b7f95ae03a7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40dcbc75-65c2-470f-8978-3b7f95ae03a7
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 13, 2026
Merged via the queue into microsoft:main with commit 66c41fa Oct 13, 2026
81 of 82 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.

BUG: CodeChameleonConverter binary_tree and length decryption functions fail during execution with TypeError and AttributeError

2 participants