Skip to content

Validate search queries during deserialization - #1598

Merged
danlamanna merged 1 commit into
masterfrom
validate-search-queries
Sep 14, 2026
Merged

danlamanna merged 1 commit into
masterfrom
validate-search-queries

Conversation

@danlamanna

@danlamanna danlamanna commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Invalid search queries now consistently return a clear HTTP 400 response across image search, facets, collection population, and ZIP downloads.
    • Search validation errors are handled consistently across supported search endpoints.
    • Valid ZIP-download queries continue to work as expected.
  • Tests

    • Added regression coverage for malformed queries across collection, image search, and ZIP-download workflows.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8c35c0b7-2309-4309-b9ed-37f1169ef7cc

📥 Commits

Reviewing files that changed from the base of the PR and between d2899bf and 623e760.

📒 Files selected for processing (8)
  • isic/core/api/image.py
  • isic/core/dsl.py
  • isic/core/forms/search.py
  • isic/core/serializers.py
  • isic/core/tests/test_api_collection.py
  • isic/core/tests/test_search.py
  • isic/urls.py
  • isic/zip_download/tests/test_zip_download.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Search query parsing now raises a shared SearchQueryParseError. Forms handle it as validation failure, while API routes allow it to reach the URL handler and return HTTP 400 responses. Regression tests cover collection population, image search size, and ZIP download.

Changes

Search query error handling

Layer / File(s) Summary
Shared parse-error contract
isic/core/dsl.py, isic/core/serializers.py, isic/core/forms/search.py
SearchQueryParseError is defined centrally. Query validation converts ParseException to this exception, and form cleaning converts it to a form validation error.
API error propagation
isic/core/api/image.py, isic/urls.py
Image search endpoints no longer catch parser exceptions locally. The URL handler now handles SearchQueryParseError and preserves the HTTP 400 response.
Invalid-query regression coverage
isic/core/tests/test_api_collection.py, isic/core/tests/test_search.py, isic/zip_download/tests/test_zip_download.py
Tests verify HTTP 400 responses for malformed queries across collection population, image search size, and ZIP download routes.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 623e7

Malformed search queries retain the intended validation behavior and HTTP 400 handling. The change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: search queries are validated during deserialization. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch validate-search-queries

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@danlamanna
danlamanna merged commit 48b81c0 into master Sep 14, 2026
3 checks passed
@danlamanna
danlamanna deleted the validate-search-queries branch September 14, 2026 19:27
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.

1 participant