fix: single-quote YAML strings with backslashes for safe round-tripping#11160
Open
NIK-TIGER-BILL wants to merge 2 commits intodeepset-ai:mainfrom
Open
fix: single-quote YAML strings with backslashes for safe round-tripping#11160NIK-TIGER-BILL wants to merge 2 commits intodeepset-ai:mainfrom
NIK-TIGER-BILL wants to merge 2 commits intodeepset-ai:mainfrom
Conversation
added 2 commits
April 20, 2026 23:37
When serializing pipelines containing regex patterns (e.g. \b, \w) or file paths with backslashes, PyYAML may emit plain scalars that are misinterpreted on load as YAML escape sequences, causing ReaderError (#x0008) or SyntaxWarning on Python 3.13+. Fix: override YamlDumper.represent_str to emit single-quoted scalars for any string containing a backslash. In single-quoted YAML scalars, no escape sequences are interpreted, so the round-trip is always safe. Closes deepset-ai#11093 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
|
Someone is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
NIK-TIGER-BILL seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
|
@anakin87 reassigning to you for review since you're assigned the issue |
anakin87
requested changes
Apr 21, 2026
Member
anakin87
left a comment
There was a problem hiding this comment.
@NIK-TIGER-BILL please sign the CLA, then I'll review
Please also take a look at failing workflows, related to format
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.
Related Issues
Proposed Changes:
When serializing pipelines containing regex patterns (e.g. `\b\w+\b`) or file paths with backslashes, PyYAML emits plain scalars that can be misinterpreted as YAML escape sequences on load. On Python 3.13+ this produces `SyntaxWarning`, and on some configurations it causes `ReaderError: unacceptable character #x0008`.
Fix: Override `YamlDumper.represent_str` to emit single-quoted YAML scalars for any string containing a backslash. In single-quoted YAML scalars, no escape sequences are interpreted, so the round-trip is always safe.
Before:
After:
Strings without backslashes continue to be emitted as plain scalars (no change).
How did you test it?
Notes for the reviewer
This is a minimal, targeted fix. An alternative approach would be to always quote all strings, but that would make the YAML output significantly more verbose for no additional safety benefit.
Checklist