Skip to content

Return 400 for search requests without identifiers#5369

Open
puneetdixit200 wants to merge 1 commit into
mem0ai:mainfrom
puneetdixit200:fix-search-missing-filter-identifiers
Open

Return 400 for search requests without identifiers#5369
puneetdixit200 wants to merge 1 commit into
mem0ai:mainfrom
puneetdixit200:fix-search-missing-filter-identifiers

Conversation

@puneetdixit200
Copy link
Copy Markdown

Summary

Fixes #5367.

POST /search now validates that the request includes at least one memory scope identifier before calling Memory.search(). After merging deprecated top-level user_id, agent_id, and run_id values into filters, the route returns 400 Bad Request when none of those identifiers is present instead of letting the backend raise and mapping that client error to a generic upstream 502.

The route also lets intentional FastAPI HTTPExceptions pass through the broad upstream error wrapper, and the regression test verifies that invalid search requests do not call the memory backend.

Testing

AUTH_DISABLED=true PYTHONPATH=server:. uv run --extra test --with-requirements server/requirements.txt --with 'psycopg[binary]' pytest tests/test_server_params.py -q
uv run --extra dev ruff check server/main.py tests/test_server_params.py
uv run --extra dev ruff format --check server/main.py
git diff --check

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Deepak kudi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

POST /search returns 502 instead of 400 for invalid filters (observed in MCP integration)

2 participants