Skip to content

Fix hybrid search metadata filters and CI failure detection - #252

Merged
hnwyllmm merged 2 commits into
oceanbase:developfrom
hnwyllmm:codex/fix-hybrid-search-filter-ci
Aug 3, 2026
Merged

Fix hybrid search metadata filters and CI failure detection#252
hnwyllmm merged 2 commits into
oceanbase:developfrom
hnwyllmm:codex/fix-hybrid-search-filter-ci

Conversation

@hnwyllmm

@hnwyllmm hnwyllmm commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • constrain the DBMS_HYBRID_SEARCH.GET_SQL rewrite to backtick-quoted JSON_EXTRACT(...) expressions
  • preserve ordinary quoted identifiers in filtered BM25, KNN, and combined hybrid-search SQL
  • keep the pytest-summary fallback required by pylibseekdb, but fail on positive failed/error(s) counts and on missing successful summaries
  • add regression tests for both the SQL rewrite and CI summary parsing

Fixes #251.

Root cause

The previous regex could start at the closing backtick of one ordinary identifier and end at the opening backtick of another whenever an unquoted JSON_EXTRACT appeared between them. That produced malformed SQL for metadata-filtered hybrid searches.

The integration tests already caught this regression, but the CI fallback required a literal ======= in pytest's final line. When the summary format did not contain that exact marker, the || exit 0 branch marked the job successful even with failures.

Validation

Local full-unit-suite note: 463 tests passed and 318 skipped; 6 existing sentence-transformer tests failed because the local transformers installation imports an unavailable huggingface_hub.is_offline_mode. This is unrelated to the changed files.

Summary by CodeRabbit

  • Bug Fixes

    • Improved hybrid search SQL handling so quoted identifiers remain intact while supported JSON extraction expressions are processed correctly.
    • Added validation to ensure test runs report a valid, passing pytest summary.
  • Tests

    • Added coverage for successful, failed, interrupted, missing, and empty test summaries.
    • Added regression tests for hybrid search SQL rewriting, including quoted identifiers and JSON extraction expressions.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@hnwyllmm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3782dd7d-5105-4e0a-a73a-1982049ecf6e

📥 Commits

Reviewing files that changed from the base of the PR and between 43598e4 and d83a9ab.

📒 Files selected for processing (2)
  • .github/scripts/check-pytest-summary.sh
  • tests/unit_tests/test_ci_pytest_summary.py
📝 Walkthrough

Walkthrough

The change adds a shared pytest-summary validator for CI and updates three workflow checks. It also narrows hybrid-search SQL rewriting to quoted JSON_EXTRACT expressions and adds regression tests for both changes.

Changes

Pytest summary validation

Layer / File(s) Summary
Shared pytest result validation
.github/scripts/check-pytest-summary.sh, .github/workflows/ci.yml, tests/unit_tests/test_ci_pytest_summary.py
The new script validates pytest log existence, content, failures, errors, and passed tests. Three CI jobs use the script. Tests cover valid, invalid, interrupted, missing-summary, and missing-file cases.

Hybrid-search SQL rewrite

Layer / File(s) Summary
Targeted JSON_EXTRACT unquoting
src/pyseekdb/client/client_base.py, tests/unit_tests/test_hybrid_search_sql_rewrite.py
Hybrid search now removes backticks only from complete JSON_EXTRACT expressions. Regression tests cover casing, parentheses, existing unquoted expressions, and adjacent quoted identifiers.

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

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes the hybrid-search regression but does not address the linked issue's filtered get() __pk_increment SQL syntax error. Add or link a fix for filtered get() SQL generation, or narrow the linked issue scope if that defect is intentionally out of scope.
Out of Scope Changes check ⚠️ Warning The CI summary script, workflow changes, and related tests are unrelated to linked issue #251's embedded-engine SQL regressions. Move the CI changes to a separate PR, or link an issue that explicitly covers CI failure detection.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the hybrid-search fix and CI failure-detection changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@hnwyllmm
hnwyllmm marked this pull request as ready for review August 3, 2026 08:10
@hnwyllmm
hnwyllmm requested a review from Copilot August 3, 2026 08:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a SQL rewrite regression in hybrid search metadata filters (caused by an overly-broad backtick/JSON_EXTRACT regex) and hardens CI failure detection by replacing a brittle tail|grep ... || exit 0 pattern with a dedicated pytest-summary validation script, with unit tests covering both behaviors.

Changes:

  • Tighten the DBMS_HYBRID_SEARCH.GET_SQL post-processing to unquote only fully backtick-quoted JSON_EXTRACT(...) expressions.
  • Replace CI’s pytest “last-line grep” fallback with .github/scripts/check-pytest-summary.sh and add unit tests for summary parsing.
  • Add regression tests ensuring adjacent identifier backticks are preserved during the SQL rewrite.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/pyseekdb/client/client_base.py Adds a constrained regex + helper to unquote only quoted JSON_EXTRACT(...) expressions in GET_SQL output.
tests/unit_tests/test_hybrid_search_sql_rewrite.py Regression tests for the SQL rewrite to ensure identifiers remain properly quoted.
.github/workflows/ci.yml Switches pytest-summary validation from inline greps to the new script.
.github/scripts/check-pytest-summary.sh New “fail-closed” pytest summary validator to catch failures even when pytest exit codes are masked.
tests/unit_tests/test_ci_pytest_summary.py Unit tests for the CI summary validation script behavior.

Comment thread .github/scripts/check-pytest-summary.sh Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pyseekdb/client/client_base.py`:
- Around line 83-85: Update _QUOTED_JSON_EXTRACT_EXPRESSION_PATTERN so it
matches only a single JSON_EXTRACT call whose closing parenthesis, allowing
optional surrounding parentheses and whitespace, terminates the expression; do
not let trailing operators or other content inside the backticks match. Add a
regression test confirming `JSON_EXTRACT(metadata, '$.category') + (1)` remains
quoted and is not unquoted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6da4191a-7789-435d-be47-400e79a8f760

📥 Commits

Reviewing files that changed from the base of the PR and between 843e15c and 43598e4.

📒 Files selected for processing (5)
  • .github/scripts/check-pytest-summary.sh
  • .github/workflows/ci.yml
  • src/pyseekdb/client/client_base.py
  • tests/unit_tests/test_ci_pytest_summary.py
  • tests/unit_tests/test_hybrid_search_sql_rewrite.py

Comment on lines +83 to +85
_QUOTED_JSON_EXTRACT_EXPRESSION_PATTERN = re.compile(
r"`(?P<expression>\s*\(*\s*JSON_EXTRACT\s*\([^`]*\)\s*\)*\s*)`",
re.IGNORECASE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restrict the matcher to one JSON_EXTRACT expression.

Line 84 lets [^]*consume text after theJSON_EXTRACTcall. For example, ``JSON_EXTRACT(metadata, '$.category') + (1)` `` matches and is unquoted. That content can be an ordinary backtick-quoted identifier.

Validate that the matching closing parenthesis terminates JSON_EXTRACT, after optional outer parentheses. Add a regression test that preserves this input.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pyseekdb/client/client_base.py` around lines 83 - 85, Update
_QUOTED_JSON_EXTRACT_EXPRESSION_PATTERN so it matches only a single JSON_EXTRACT
call whose closing parenthesis, allowing optional surrounding parentheses and
whitespace, terminates the expression; do not let trailing operators or other
content inside the backticks match. Add a regression test confirming
`JSON_EXTRACT(metadata, '$.category') + (1)` remains quoted and is not unquoted.

@hnwyllmm
hnwyllmm merged commit 82e4989 into oceanbase:develop Aug 3, 2026
9 checks passed
@hnwyllmm
hnwyllmm deleted the codex/fix-hybrid-search-filter-ci branch August 3, 2026 08:45
hnwyllmm added a commit that referenced this pull request Aug 3, 2026
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.

[Bug]: pyseekdb 1.4.0 broken against embedded engine (__pk_increment SQL syntax error + empty BM25-only hybrid leg)

2 participants