Skip to content

fix: RegexTextExtractor bool var to change output from { } to {"captured_text": ""} - #10152

Merged
davidsbatista merged 7 commits into
mainfrom
fix/RegexTextParser
Dec 2, 2025
Merged

davidsbatista merged 7 commits into
mainfrom
fix/RegexTextParser

Conversation

@davidsbatista

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

  • Added a return_empty_on_no_match parameter (default True) to RegexTextExtractor.__init__()
  • When set to False, the component returns {"captured_text": ""} instead of {} when no regex match is found.
  • Provides a consistent output structure for pipeline integration.

A deprecation warning is emitted when using the default behaviour (return_empty_on_no_match=True), indicating that future releases will change the default to return {"captured_text": ""} instead of {}.

Existing pipelines using RegexTextExtractor continue to work without changes, as the default behaviour remains return_empty_on_no_match=True.

How did you test it?

Added tests to assert the use of the new variable, and all existing tests pass

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel

vercel Bot commented Nov 27, 2025 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
haystack-docs Ready Ready Preview Comment Dec 2, 2025 2:40pm

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Nov 27, 2025
@coveralls

coveralls commented Nov 27, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 19861357461

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 22 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.6%) to 92.182%

Files with Coverage Reduction New Missed Lines %
components/extractors/regex_text_extractor.py 2 95.65%
components/tools/tool_invoker.py 4 96.0%
core/pipeline/breakpoint.py 8 88.59%
core/pipeline/pipeline.py 8 91.74%
Totals Coverage Status
Change from base Build 19737955616: 0.6%
Covered Lines: 14044
Relevant Lines: 15235

💛 - Coveralls

@davidsbatista davidsbatista changed the title Fix/regex text parser fix: RegexTextExtractor bool var to change output from { } to {"captured_text": ""} Nov 27, 2025
@davidsbatista
davidsbatista marked this pull request as ready for review November 27, 2025 14:32
@davidsbatista
davidsbatista requested a review from a team as a code owner November 27, 2025 14:32
@davidsbatista
davidsbatista requested review from bglearning and vblagoje and removed request for a team November 27, 2025 14:32
@davidsbatista

Copy link
Copy Markdown
Contributor Author

@bglearning happy to also have your feedback

@vblagoje vblagoje left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, minor suggested changes would be nice to have


:param regex_pattern:
The regular expression pattern used to extract text.
The pattern should include a capture group to extract the desired text.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:param return_empty_on_no_match missing

return {}
result = self._extract_from_text(last_message.text)
return RegexTextExtractor._build_result(result)
return RegexTextExtractor._build_result(self, result)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be self, let's fix it.

:returns:
- If match found: `{"captured_text": "matched text"}`
- If no match and `return_empty_on_no_match=True`: `{}`
- If no match and `self.return_empty_on_no_match=True`: `{}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if no match and self.return_empty_on_no_match=False: {"captured_text": ""}?

@vblagoje vblagoje left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LG

This branch was successfully deployed

1 active deployment
Preview — 9dd866e9 Deployed Dec 2, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return empty text handle on no match for RegexTextExtractor

3 participants