fix(gateway): fix underscore-stripping regex to preserve snake_case identifiers#15451
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(gateway): fix underscore-stripping regex to preserve snake_case identifiers#15451Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
Conversation
…dentifiers The blanket _(.+?)_ and __(.+?)__ patterns incorrectly consumed snake_case identifiers like send_as_bot and user_id. Add lookbehind/lookahead boundaries so underscores adjacent to alphanumeric characters are not treated as markdown formatting. Same fix already applied and tested in the CLI renderer; this addresses the gateway/platforms/helpers.py copy. Supersedes NousResearch#15076.
Collaborator
Contributor
Author
|
Closing — the fix is now on main via an alternative regex. On current
Same goal, same outcome ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The blanket
_(.+?)_and__(.+?)__patterns ingateway/platforms/helpers.pyincorrectly consumed snake_case identifiers likesend_as_botanduser_id. This adds lookbehind/lookahead boundaries ((?<![a-zA-Z0-9])/(?![a-zA-Z0-9])) so underscores adjacent to alphanumeric characters are not treated as markdown formatting.The same fix was already applied and tested in the CLI renderer (
cli.py); this addresses the gateway copy.Related Issue
Supersedes #15076.
Type of Change
Changes Made
gateway/platforms/helpers.py— added non-alphanumeric boundary assertions to_RE_BOLD_UNDERand_RE_ITALIC_UNDERso they only match real Markdown delimitersHow to Test
pytest -k test_snake_case_preserved—send_as_bot,user_idsurvive strippingpytest -k test_bold_underscore_stripped— actual__bold__formatting is strippedpytest -k test_italic_underscore_stripped— actual_italic_formatting is strippedpytest -k test_double_underscore_in_identifier_preserved—my_var__namesurvivespytest -k test_config_keys_preserved—max_tokens,api_base_urlsurvivepytest -k test_asterisk_bold_unaffected—**bold**still workspytest -k test_mixed_formatting_and_identifiers— both formatting and identifiers handled correctlypytest -k test_multiple_snake_case_in_one_line— multiple identifiers in one lineChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs