Skip to content

fix(regex): preserve significant whitespace during extraction - #4160

Open
Wang-MuFF wants to merge 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/regex-preserve-whitespace
Open

Wang-MuFF wants to merge 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/regex-preserve-whitespace

Conversation

@Wang-MuFF

Copy link
Copy Markdown

Summary

Fixes #4159.

Preserve the supplied content and regular expression instead of stripping them before matching. A literal-space pattern currently becomes an empty pattern, while anchored whitespace and trailing newlines disappear from the input. The runtime fix removes the two strip() calls and retains the existing result format and regex engine.

Release Notes

Fix Regex Extract discarding significant spaces, tabs and newlines from input content and regular expressions.

Change Type

  • Non-LLM plugin (tools, extensions, datasource, etc.)

Screenshots / Videos

Real SDK and packaged-plugin HTTP reproductions:

Content / expression Before After
a b c / a single space Invalid expression plus empty matches Three space matches
a foo b / foo ['foo'] [' foo ']
foo\n / \n$ [] ['\n']

Version

  • Bump the top-level manifest patch version from 0.0.10 to 0.0.11.
  • Declare dify_plugin>=0.10.2,<0.11.0 and update its lock metadata; no locked dependency versions changed.

Testing

  • Clean local packaged-plugin runtime: Python 3.12.10, Dify Plugin SDK 0.10.2, frozen dependencies.
  • Full Dify deployment / SaaS.
Coverage Result
Meaningful whitespace: literal spaces, padded patterns, anchors, newlines, tabs and whitespace-only content Six cases fail before the fix and pass afterward
Ordinary digits, no matches, capture groups and malformed expressions Four preservation cases pass before and afterward
  • uv run --locked --with pytest==9.0.2 python -m pytest tests -q: 10 passed.
  • The new tests pass Black; source and tests pass Ruff. git diff --check passes.
  • Official Dify CLI v0.6.13 successfully packages the staged plugin. The extracted artifact installs in a fresh frozen environment and passes all 10 tests.
  • The extracted artifact's real serverless /health returns 200; HTTP /invoke preserves spaces and trailing newlines, with an ordinary digit-extraction control. The same space-pattern HTTP assertion fails on the unchanged baseline. Probe processes are stopped after each run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex Extract removes significant whitespace from content and patterns

1 participant