Skip to content

fix metadata parsing exception in document_store.py#134

Open
salvogs wants to merge 1 commit into
pathwaycom:mainfrom
salvogs:main
Open

fix metadata parsing exception in document_store.py#134
salvogs wants to merge 1 commit into
pathwaycom:mainfrom
salvogs:main

Conversation

@salvogs

@salvogs salvogs commented Nov 7, 2025

Copy link
Copy Markdown

Bug Report: JMESPath Filter Parse Error with Escaped Single Quotes

Problem Description
The _get_jmespath_filter function in [document_store.py] causes a parsing error when processing metadata filters that contain single quotes. The function incorrectly escapes single quotes by adding backslashes, which creates invalid JMESPath syntax.

Error Message:

pathway.engine.EngineError: Parse error: Invalid character: \ (line 0, column 11)
(category=='food')

Root Cause:

In line 38 of [document_store.py], the function performs this transformation:

metadata_filter.replace("'", r"\'").replace("`", "'").replace('"', "")

When a metadata filter like category=='food' is processed, it becomes category=='food', which contains escaped single quotes that are invalid in JMESPath syntax.

Fix server crash when passing metadata to running DocumentStoreServer

pathway.engine.EngineError: Parse error: Invalid character: \ (line 0, column 11)
(category==\'food\')
@CLAassistant

CLAassistant commented Nov 7, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@szymondudycz

Copy link
Copy Markdown
Contributor

Hey @salvogs, thanks for this pull request - after looking at this issue I agree that this needs to be fixed. I think, however, that you should completely remove the whole line. More importantly, currently our tests are incorrect and would fail after your change (in python/pathway/xpack/llm/tests), so these would need to be fixed. Finally, this change would require an entry in the changelog, marking this change as breaking.

@biplavbarua biplavbarua left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. usage of backticks in metadata keys/values is a common trap for JmesPath.

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.

4 participants