Repository navigation
fix: return an empty string when RegexTextExtractor's group does not participate - #13500
xubenqiang wants to merge 1 commit into
Conversation
…participate `RegexTextExtractor._extract_from_text` returned `match.group(1)` even when the first group did not participate in the match (for example `Score: (\d+)|N/A`nagainst `N/A`), so `run` produced `None` although the component declares a `str` output. Return `"` in that case, matching the no-match value, and cover both an alternation and an optional group. Re-lands the fix from deepset-ai#12896, which was closed by the first-PR limit. Fixes deepset-ai#13484
|
@xubenqiang is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @xubenqiang, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
chrikrah
left a comment
There was a problem hiding this comment.
@xubenqiang the #13484 script now prints '' where it printed None. Nothing blocks a merge here.
# git archive c50f042 (merge base 8e38c63), Python 3.12, run from the export root
$ python repro.py # the #13484 script
{'captured_text': '7'}
{'captured_text': ''}
{'captured_text': ''}
# with regex_text_extractor.py from 8e38c63 the last two print None, and your two new tests fail here too
# not run: the rest of the suite, ruff
Could you sign the CLA? Until then the bot keeps this in draft.
|
Hi @xubenqiang, just a friendly reminder: this PR is still in draft because the Contributor License Agreement (CLA) hasn't been signed yet. We'd love to review your contribution! Please sign the CLA via the link in the |
|
We can't review/merge approve without you signing the CLA |
Fixes #13484
Related Issues
Proposed Changes
RegexTextExtractor._extract_from_textreturnedmatch.group(1)whenever the pattern had groups, even when the first group did not participate in the match:The component declares
stroutput, soNonebroke downstream components. The no-match path already returns""; do the same when the group captured nothing.How did you test it?
Two new tests cover an alternation whose first branch does not match and an optional first group. With the source change reverted, exactly those two fail:
Also ran
ruff checkandruff format --checkon both changed files: clean.Notes for the reviewer
This re-lands the fix from #12896, which the first-PR limit closed while #12863 was pending. Credit to @gauravch-code for the original change.
No release note for docs/CI, but this is user-facing, so I added
releasenotes/notes/regex-text-extractor-empty-capture-group-5f3c9a1e7d2b4a68.yaml.