Skip to content

Conversation

@Deven009
Copy link
Contributor

Description

The getNonWildcardSequence method incorrectly handled cases where an escaped backslash was followed by a wildcard character. It would check if the character before a wildcard was a backslash, but didn't account for that backslash itself being escaped.

For example, the query "some\" (matching strings containing "some") would incorrectly return "some\*" instead of "some\", causing invalid ngrams containing the wildcard character to be generated.

The fix counts consecutive backslashes before wildcards:

  • Even count: wildcard is NOT escaped
  • Odd count: wildcard IS escaped

Related Issues

Resolves #19719

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Contributor

❌ Gradle check result for bd3dcf8: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

…earch-project#19719)

The getNonWildcardSequence method incorrectly handled cases where an
escaped backslash was followed by a wildcard character. It would check
if the character before a wildcard was a backslash, but didn't account
for that backslash itself being escaped.

For example, the query "*some\\*" (matching strings containing "some\")
would incorrectly return "some\\*" instead of "some\\", causing invalid
ngrams containing the wildcard character to be generated.

The fix counts consecutive backslashes before wildcards:
- Even count: wildcard is NOT escaped
- Odd count: wildcard IS escaped

Signed-off-by: Deven Prajapati <pdevens09@gmail.com>
Signed-off-by: Deven009 <pdevens09@gmail.com>
@Deven009 Deven009 force-pushed the deven009/fix/wildcard-escaped-backslash-19719 branch from bd3dcf8 to 95fe858 Compare October 30, 2025 03:51
@github-actions
Copy link
Contributor

❌ Gradle check result for 95fe858: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Deven009 and others added 2 commits October 29, 2025 21:59
Signed-off-by: Deven009 <pdevens09@gmail.com>
Signed-off-by: Deven009 <37845204+Deven009@users.noreply.github.com>
@github-actions
Copy link
Contributor

❕ Gradle check result for d2a4ad5: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.49%. Comparing base (a036313) to head (d2a4ad5).
⚠️ Report is 86 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19756      +/-   ##
============================================
+ Coverage     73.15%   73.49%   +0.33%     
- Complexity    71118    71439     +321     
============================================
  Files          5754     5754              
  Lines        325298   325304       +6     
  Branches      47052    47054       +2     
============================================
+ Hits         237975   239067    +1092     
+ Misses        68154    67295     -859     
+ Partials      19169    18942     -227     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@jainankitk jainankitk left a comment

Choose a reason for hiding this comment

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

Looks good to me! Maybe @msfroh can take another look before merging it

@Deven009
Copy link
Contributor Author

Deven009 commented Nov 4, 2025

Thank you @jainankitk for reviewing it.

Copy link
Contributor

@msfroh msfroh left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks, @Deven009!

@msfroh
Copy link
Contributor

msfroh commented Nov 25, 2025

Not sure why the "assemble" and "precommit" steps for JDK21 on macos-15 are still pending.

@Deven009 -- if they don't start running in the next ~1 hour, can you please close and reopen the PR? (That is, just click "Close pull request" at the bottom of this page, followed by "Reopen pull request".) That will retrigger all of the checks. Worst case, if the Gradle Check step fails, we can retry it.

@jainankitk jainankitk closed this Nov 25, 2025
@jainankitk jainankitk reopened this Nov 25, 2025
@github-actions
Copy link
Contributor

✅ Gradle check result for d2a4ad5: SUCCESS

@Deven009
Copy link
Contributor Author

Thank you for your review @msfroh
Thank you @jainankitk

kkewwei pushed a commit to kkewwei/OpenSearch that referenced this pull request Nov 28, 2025
…earch-project#19719) (opensearch-project#19756)

The getNonWildcardSequence method incorrectly handled cases where an
escaped backslash was followed by a wildcard character. It would check
if the character before a wildcard was a backslash, but didn't account
for that backslash itself being escaped.

For example, the query "*some\\*" (matching strings containing "some\")
would incorrectly return "some\\*" instead of "some\\", causing invalid
ngrams containing the wildcard character to be generated.

The fix counts consecutive backslashes before wildcards:
- Even count: wildcard is NOT escaped
- Odd count: wildcard IS escaped

---------

Signed-off-by: Deven Prajapati <pdevens09@gmail.com>
Signed-off-by: Deven009 <pdevens09@gmail.com>
Signed-off-by: Deven009 <37845204+Deven009@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers Search:Query Capabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Wildcard Query: Escaped Backslash before operator

3 participants