Skip to content

fix: handle escaped single quotes when formatting multiline strings - #454

Open
Sanjays2402 wants to merge 1 commit into
mirumee:mainfrom
Sanjays2402:fix/multiline-escaped-quotes
Open

fix: handle escaped single quotes when formatting multiline strings#454
Sanjays2402 wants to merge 1 commit into
mirumee:mainfrom
Sanjays2402:fix/multiline-escaped-quotes

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #423

format_multiline_strings matched concatenated single-quoted literals with ('.*?'\s*){2,} and extracted them with '.*', neither of which accounts for a backslash-escaped quote. A GraphQL operation containing ' (such as a ShopifyQL WHERE landing_page_type = 'Product' argument) had its literal truncated at the escaped quote, so convert_to_multiline_string emitted a malformed triple-quoted string and codegen aborted with black.parsing.InvalidInput.

Both patterns now share a SINGLE_QUOTED_STRING regex that skips escaped characters, and convert_to_multiline_string decodes the literal via ast.literal_eval instead of stripping every ' (falling back to the previous behavior for input that is not a valid literal). New test in tests/test_utils.py fails without the fix and passes with it.

format_multiline_strings used the regex `('.*?'\s*){2,}` to find
concatenated single-quoted string literals, and `'.*'` to extract them.
Neither accounts for a backslash-escaped quote, so a GraphQL operation
containing `'` (e.g. a ShopifyQL `WHERE type = 'Product'` argument) had
its literal truncated at the escaped quote. convert_to_multiline_string
then stripped quotes blindly, emitting a broken triple-quoted string and
codegen aborted with black.parsing.InvalidInput.

Both patterns now use a shared SINGLE_QUOTED_STRING regex that skips
escaped characters, and convert_to_multiline_string decodes the literal
with ast.literal_eval (falling back to the old behavior for input that
is not a valid literal).

Closes mirumee#423
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a2ec2d9-28d2-4d97-9945-50a914bf1dbd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Client generation doesn't handle multiline strings in the queries file

1 participant