Repository navigation
fix: return an empty string when RegexTextExtractor's first group is not part of the match - #13649
Conversation
Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
…not part of the match Fixes #13484 Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
|
@chrikrah is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @chrikrah, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
|
"" is right. The group captured nothing, and "" is already what a failed match returns, so callers only need one emptiness check. Falling back to group(0) would hand back text the pattern wasn't asked to capture. I pushed a small follow-up: the run() docstring now mentions this case, and there's a test for the ChatMessage input path. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
davidsbatista
left a comment
There was a problem hiding this comment.
Looks good, thanks!
Related Issues
Proposed Changes:
_extract_from_textreturnedmatch.group(1)whenever the pattern had a group, and that isNonewhen the group sits on the other side of an alternation (Score: (\d+)|N/Aon "N/A") or is optional and unmatched. The component declarescaptured_text=str, so it now returns"", the value a failed match already gives. It is the fix from #12896 (gauravch-code), closed at the first-PR limit, and #13500 (xubenqiang), closed today on the unsigned CLA.How did you test it?
Both patterns from the issue, as one parametrized test.
Notes for the reviewer
A pipeline that tested
captured_text is Nonenow sees"", as for no match. I kept""overgroup(0)so a caller has one empty value to test for.Checklist
@davidsbatista, you added the component in #9879. Is
""right, or should an unmatched group fall back to the whole match?