Skip to content

Resolve case-sensitivity in QueryParser to support Chapters/Members search#3844

Merged
arkid15r merged 5 commits intoOWASP:mainfrom
saichethana28:query-parser-case-integrity
Feb 9, 2026
Merged

Resolve case-sensitivity in QueryParser to support Chapters/Members search#3844
arkid15r merged 5 commits intoOWASP:mainfrom
saichethana28:query-parser-case-integrity

Conversation

@saichethana28
Copy link
Contributor

Proposed change

Resolves #3791

Fixed the logic in query_parser.py to resolve the reported blocker regarding search query processing. The changes ensure that query tokens are handled with proper case integrity and logical structure, preventing the parser from failing on specific edge cases.

Changes included:

  • Refactored token handling in backend/apps/common/search/query_parser.py.
  • Added and updated unit tests in backend/tests/apps/common/search/query_parser_test.py to verify the fix and ensure no regressions.
  • Verified that all backend tests pass and coverage is maintained.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved structured search query parsing to properly handle case sensitivity.
  • Tests

    • Added test cases validating parsing of quoted multi-word search values and case sensitivity behavior in query operations.

Walkthrough

The changes add test coverage for QueryParser case sensitivity handling and configure the structured search to use case-sensitive parsing mode to preserve field value casing while normalizing field names.

Changes

Cohort / File(s) Summary
Query Parser Tests
backend/tests/apps/common/search/query_parser_test.py
Added two test cases: test_quoted_multi_word_values verifies parsing of quoted multi-word fields with lowercasing in non-case-sensitive mode; test_case_sensitivity_toggle verifies case preservation when case_sensitive=True.
API Search Configuration
backend/apps/api/rest/v0/structured_search.py
Modified QueryParser instantiation in apply_structured_search to pass case_sensitive=True, enabling preservation of original field value casing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • kasya
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Resolve case-sensitivity in QueryParser to support Chapters/Members search' directly and specifically addresses the primary change: fixing QueryParser case-sensitivity behavior.
Description check ✅ Passed The PR description is related to the changeset, referencing issue #3791 and describing changes to query_parser.py and test files.
Linked Issues check ✅ Passed The PR changes align with issue #3791 requirements: enabling case_sensitive=True in structured_search.py and adding tests to verify case preservation behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving the QueryParser case-sensitivity issue; test additions and parser configuration changes are within scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
backend/tests/apps/common/search/query_parser_test.py (2)

212-218: Good coverage for multi-word quoted values.

Consider also asserting the field and type keys (e.g., results[0]["field"] == "project") to guard against regressions in field parsing alongside the value check. This is optional.


220-223: Test named "toggle" but only verifies the case-sensitive path.

To live up to the name "toggle", consider also asserting the non-case-sensitive parser lowercases the same value, and that the field name is normalized to lowercase in both cases. This strengthens the test as a true contrast.

♻️ Suggested enhancement
     def test_case_sensitivity_toggle(self):
         query = "Author:OWASP"
         cs_result = self.case_sensitive_parser.parse(query)
+        ci_result = self.parser.parse(query)
+
+        assert cs_result[0]["field"] == "author"
         assert cs_result[0]["value"] == "OWASP"
+
+        assert ci_result[0]["field"] == "author"
+        assert ci_result[0]["value"] == "owasp"

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 and usage tips.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 8, 2026
cubic-dev-ai[bot]
cubic-dev-ai bot previously approved these changes Feb 8, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@saichethana28 saichethana28 marked this pull request as ready for review February 8, 2026 07:10
@saichethana28
Copy link
Contributor Author

Hi @arkid15r, could you please review this? I've fixed the QueryParser case-sensitivity for Chapters/Members. Once this blocker is resolved, I’m ready to start extending structured search to other entities

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 8, 2026
@saichethana28
Copy link
Contributor Author

@cubic-dev-ai review this pull request

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 8, 2026

@cubic-dev-ai review this pull request

@saichethana28 I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Confidence score: 3/5

  • The change in backend/apps/common/search/query_parser.py ignores the case_sensitive flag for string values, which can break expected case-insensitive search behavior for users.
  • This carries some user-impacting regression risk, so the merge risk is moderate despite being a localized change.
  • Pay close attention to backend/apps/common/search/query_parser.py - case_sensitive is no longer applied to string query inputs.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="backend/apps/common/search/query_parser.py">

<violation number="1" location="backend/apps/common/search/query_parser.py:191">
P2: The `case_sensitive` parameter is now ignored for string values, likely breaking case-insensitive search behavior.

Previously, `query = query.lower()` ensured that if `case_sensitive=False` (the default), all inputs were lowercased. By removing this global normalization without adding value-specific normalization in `parse` or `to_dict`, the parser now preserves the case of values (e.g., `Title:Value`) even when `case_sensitive` is `False`.

This changes the contract of the class and may regress existing search functionality that expects case-insensitive normalization.

**Fix Suggestion:**
Apply lowercasing to string values when `case_sensitive` is `False`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 8, 2026
@saichethana28
Copy link
Contributor Author

@cubic-dev-ai review this pull request

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 8, 2026

@cubic-dev-ai review this pull request

@saichethana28 I have started the AI code review. It will take a few minutes to complete.

cubic-dev-ai[bot]
cubic-dev-ai bot previously approved these changes Feb 9, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@saichethana28
Copy link
Contributor Author

@arkid15r, let me know if this looks good to you or if any changes are needed

@arkid15r arkid15r enabled auto-merge February 9, 2026 05:29
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 2026

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

Would this work?

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.68%. Comparing base (6c59166) to head (8e2ba2c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3844   +/-   ##
=======================================
  Coverage   93.68%   93.68%           
=======================================
  Files         463      463           
  Lines       14420    14420           
  Branches     1939     1939           
=======================================
  Hits        13509    13509           
  Misses        535      535           
  Partials      376      376           
Flag Coverage Δ
backend 95.65% <100.00%> (ø)
frontend 88.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/apps/api/rest/v0/structured_search.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c59166...8e2ba2c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@saichethana28
Copy link
Contributor Author

Would this work?

Yes, this works. Moving the .lower() call to the start of the parser is a much cleaner optimization. Since structured_search.py explicitly passes case_sensitive=True, it correctly skips that block and preserves the casing for Chapter names. The refactor looks solid

@arkid15r arkid15r added this pull request to the merge queue Feb 9, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2026
…earch (#3844)

* resolve query parser blocker

* use case_sensitive flag in QueryParser

* feat: add case_sensitive option to QueryParser and update tests

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
@arkid15r arkid15r removed this pull request from the merge queue due to a manual request Feb 9, 2026
@arkid15r arkid15r added this pull request to the merge queue Feb 9, 2026
Merged via the queue into OWASP:main with commit 8b5c58c Feb 9, 2026
35 checks passed
arkid15r added a commit that referenced this pull request Feb 10, 2026
* Run make update

* Clean up snapshot generated videos

* Update backend/data/nest.dump

* feat(ui): revamp corporate supporters carousel (Infinite Marquee + Dark Mode fix) (#3837)

* feat(ui): revamp corporate supporters carousel (Infinite Marquee + Dark Mode fix)

* fix: resolve failing test case

* fix: add fallback text for unnamed sponsors

* docs: add docstrings to satisfy coverage requirements

* Run make check and fix tests.

---------

Co-authored-by: Kate <kate@kgthreads.com>

* Fix/redundant typescript assertion (#3834)

* Fix Sonar S4325 by narrowing session user fields instead of casting

* Fix unused ExtendedSession in mentorship page

* fix: redundant-typescript-assertion

* Fix stale latest date displayed in Project Health Dashboard metrics (#3842)

* Fixed latest date in proejct health dashboard

* updated order

* Update code

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>

* feat: improve backend test coverage to 96% (#3840)

* feat: improve backend test coverage to 96%

* fix comments

* fix issues

* fix issue

* fix cubic-dev-ai comments

* Update code

* Fix tests

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Fix: merge consecutive RUN instructions in frontend Dockerfile (#3644)

* Fix: merge consecutive RUN instructions in frontend Dockerfile

* fix: comment Dockerfile note to prevent syntax error

* Update code

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Fix 'is_merged' not being available on the Issue (#3843)

* Fix 'is_merged' not being available on the Issue

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>

* CI:  Add ansible-lint workflow for Ansible playbooks (#3796)

* ci: add ansible-lint workflow

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* Update .github/workflows/lint-ansible.yaml

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* ci: add ansible-lint make target and workflow

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* ci: add ansible-lint pre-commit hook

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* fix: whitespace & version

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* Update Makefile

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* ci: enable ansible-lint scanning and add requirements.yml

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* chore(ansible):align linting and module usage

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* ci(ansible): install collections before deploy playbooks

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* Update code

* Update code

* Update .github/workflows/run-ci-cd.yaml

---------

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>

* Fix ElevenLabs API error (#3861)

* use default liam voice

* bump speed by 0.10

---------

Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Add Ime Iyonsi to MENTORS.md (#3866)

* Add mentor profile for Ime Iyonsi

Added Ime Iyonsi's mentor profile.

* Fix GitHub link for Ime Iyonsi

Corrected GitHub link for Ime Iyonsi.

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>

* Update MENTORS.md

* Enabled Strict Mode (#3776)

* Enabled Strict Mode

* fixed ai review

* fix

* fixed review

* fix

* update test

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Resolve case-sensitivity in QueryParser to support Chapters/Members search (#3844)

* resolve query parser blocker

* use case_sensitive flag in QueryParser

* feat: add case_sensitive option to QueryParser and update tests

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Update dependencies (#3874)

* Update dependencies

* Bump django-ninja version

* fix(proxy): pin nginx and certbot images (#3848)

* fix(proxy): pin nginx and certbot images

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

* fix stable verssions

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>

---------

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* Update docker-compose/proxy/compose.yaml

* Update backend/pyproject.toml

* Update ansible lint configuration (#3880)

* Update .github/ansible/.ansible-lint.yaml

* Improve frontend test coverage above 80% and add missing test files (#3864)

* Imrove test coverage to 80% and added test

* Fixed coderabbit review

* update code

* fixed coderabbit ai

* fixed soanrqube warning

* fixed review

* update

* fixed aloglia cache_key (#3825)

* fixed aloglia cache_key

* change separator val to be semicolon (;)

* Update code

* add tests + use json filters

* add trailing newline

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

* fix: remove unused className prop from AnchorTitle component (#3822)

* fix: remove unused className prop from AnchorTitle component

Fixes #3805

The className prop was defined in AnchorTitleProps but never used
in the component implementation. Removing it resolves Sonar rule
typescript:S6767 and improves code maintainability.

* fix: use className prop instead of removing it

- Added className back to AnchorTitleProps interface
- Accept className parameter in component
- Apply className to root div element
- Resolves reviewer feedback on PR #3822

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>

---------

Signed-off-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>
Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Yashraj Pahuja <yashrajpahuja9999@gmail.com>
Co-authored-by: Kate <kate@kgthreads.com>
Co-authored-by: CodeAritraDhank <aritradhank21@gmail.com>
Co-authored-by: Anurag Yadav <143180737+anurag2787@users.noreply.github.com>
Co-authored-by: Harshit Verma <harshit1092004@gmail.com>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
Co-authored-by: Shuban Mutagi <shubanmutagi55@gmail.com>
Co-authored-by: Muhammad Hassaan Saleem <iamhassaans@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: emaybu <152900874+emaybu@users.noreply.github.com>
Co-authored-by: sai chethana <saichethanavesireddy@gmail.com>
Co-authored-by: Rahul Paul <179798584+Mr-Rahul-Paul@users.noreply.github.com>
Co-authored-by: Lavanya <lavanyayadawad30@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Blocker for #3777] Fixing QueryParser case-sensitivity to support Chapters/Members search

2 participants