Skip to content

fix(api): return formula default validation errors - #9271

Merged
generall merged 1 commit into
qdrant:devfrom
skarL007:fix/formula-query-defaults-validation
Jun 3, 2026
Merged

generall merged 1 commit into
qdrant:devfrom
skarL007:fix/formula-query-defaults-validation

Conversation

@skarL007

@skarL007 skarL007 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

FormulaQuery::validate collected validation errors for invalid defaults, but returned Ok(()) unconditionally after the loop.

This PR returns the collected errors when present and adds focused unit coverage for:

  • invalid default variable names
  • non-numeric $score defaults
  • valid numeric $score and payload defaults

Tests

  • cargo +nightly fmt --all -- --check

I also attempted cargo test -p api formula_query --locked, but this Windows environment is missing the MSVC linker (link.exe / Visual C++ Build Tools), so local Rust compilation stops before the crate builds. I’m relying on CI for compile/test validation.

AI disclosure

  • [AI-assisted] fix(api): return formula default validation errors
  • Initial prompt used: Implement the FormulaQuery::validate audit finding: return collected default validation errors and add focused regression tests; keep the change limited to lib/api/src/rest/validate.rs.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: dfae0cad-44e7-4b8b-88ab-ff4898473c7a

📥 Commits

Reviewing files that changed from the base of the PR and between c7e5703 and a1362a9.

📒 Files selected for processing (1)
  • lib/api/src/rest/validate.rs

📝 Walkthrough

Walkthrough

This pull request fixes the FormulaQuery::validate method to properly return validation errors. Previously, the validation method always returned success even when validation errors were accumulated. The change adds branching logic to return Err(errors) when validation errors exist, otherwise Ok(()). The PR includes three new unit tests covering validation of default variable names, enforcement of numeric $score defaults, and acceptance of valid numeric $score combined with payload defaults.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A query once always smiled,
Though errors crept wild—
Now validation's sincere,
With tests crystal clear,
Bugs caught before they compile!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 title directly describes the main fix: returning formula default validation errors instead of unconditionally returning success.
Description check ✅ Passed The description clearly explains the bug fix, the solution, test coverage, and testing approach, all directly related to the changeset.
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.

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


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.

@generall

generall commented Jun 3, 2026

Copy link
Copy Markdown
Member

thanks!

@generall
generall merged commit 9edddf6 into qdrant:dev Jun 3, 2026
15 checks passed
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.

2 participants