fix(labels): escape single quotes in custom label descriptions#2320
fix(labels): escape single quotes in custom label descriptions#2320
Conversation
When custom label descriptions contain single quotes (e.g., "Don't merge"),
the generated `custom_labels_class` Enum produces malformed Python string
literals. This adds `.replace("'", "\\'")` to escape embedded single quotes
before wrapping the description in single-quote delimiters.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review Summary by QodoEscape single quotes in custom label descriptions
WalkthroughsDescription• Escape single quotes in custom label descriptions • Prevents malformed Python string literals in generated Enum • Fixes labels with apostrophes like "Don't merge" Diagramflowchart LR
A["Custom label description<br/>with single quote"] -->|escape single quotes| B["Properly formatted<br/>Python string literal"]
B -->|generate Enum| C["Valid custom_labels_class"]
File Changes1. pr_agent/algo/utils.py
|
Code Review by Qodo
|
… key Add defensive check so set_custom_labels() handles cases where the label value is not a dict or is missing the 'description' key, instead of raising a KeyError/TypeError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Persistent review updated to latest commit 9314319 |
Summary
set_custom_labels()inpr_agent/algo/utils.pywraps label descriptions in single quotes without escaping. A description likeDon't mergeproduces the malformed string'Don't merge', breaking the generatedcustom_labels_classEnum schema sent to the LLM..replace("'", "\\'")to escape single quotes in descriptions before they are wrapped in single-quote delimiters. This is chained after the existing.replace('\n', '\\n')call on line 959.pr_description.pyandpr_generate_labels.pysince both call the sharedset_custom_labels()utility.Test plan
description = "Don't merge this")/describeor/generate_labelsand verify the generatedcustom_labels_classcontains properly escaped strings🤖 Generated with Claude Code