Skip to content

fix(#902,#903,#907): HTTP temporal filters, limit cap, empty query guard - #911

Merged
ajianaz merged 1 commit into
developfrom
fix/http-temporal-limits-query-guard
Aug 6, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/http-temporal-limits-query-guard

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What

Three HTTP API fixes bundled (same file scope — server crate only):

#902 — Temporal range filters (before/after)

  • Add before and after fields to RecallRequest (RFC3339 timestamps)
  • Post-filter results by created_at in both unified and memory-only recall paths
  • Invalid timestamps return 400 with descriptive error

#903 — Limit cap (DoS prevention)

  • Add MAX_LIMIT = 100 constant in types.rs
  • limit field is silently capped (req_data.limit.min(MAX_LIMIT))
  • Prevents unbounded query attacks via limit: 999999

#907 — Empty query guard

  • Reject empty/whitespace-only query strings with 400
  • Previously returned misleading top-N results (recency-based, not relevance)

Why

Issue Impact Severity
#902 before/after params silently ignored — temporal queries broken 🔴 P0
#903 No limit cap — DoS vector via unbounded queries 🟠 P1
#907 Empty query returns misleading results 🟡 P2

Testing

  • ✅ cargo check --workspace — pass
  • ✅ cargo clippy --workspace --all-targets -- -D warnings — clean
  • ✅ cargo test --workspace — 454 passed, 0 failed, 26 ignored
  • ✅ cargo run -p docgen — API docs regenerated (before/after fields visible)
  • ✅ cargo fmt --all — formatted

Closes #902, #903, #907.

#902: Add before/after RFC3339 fields to RecallRequest. Post-filter
results by created_at in both unified and memory-only recall paths.
Invalid timestamps return 400.

#903: Cap limit at MAX_LIMIT (100) to prevent DoS via unbounded queries.

#907: Reject empty/whitespace query strings with 400 instead of returning
misleading top-N results.
Comment thread crates/uteke-server/src/handlers.rs Dismissed
Comment thread crates/uteke-server/src/handlers.rs Dismissed
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-server/src/handlers.rs:371 — The temporal range post-filter (results.retain(...)) is applied inside the Some(Ok(mut results)) arm before the if api_version == Some(ApiVersion::V1) check. However, the v1 path constructs v1_results from results — so the filter IS applied. But wait, looking more carefully: the filter is applied, then the v1 branch builds from the filtered results. This is actually correct. Let me re-examine... The filter runs on results before either the v1 or v2 serialization path, so both paths get filtered. This is fine.
  • crates/uteke-server/src/handlers.rs:371 — The temporal post-filter (results.retain(...)) is only applied in the Some(Ok(mut results)) (unified) and Ok(mut results) (recall_result) arms. However, when unified_result is None and recall_result is Err, or when the code takes other branches (e.g., FTS5-only or graph-only strategies that might not produce a unified result), the temporal filter is silently skipped. If a user specifies strategy=fts5 and the code path doesn't go through unified or the filtered recall_result arm, after/before filters are ignored, returning results outside the requested range without any error.

Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 3b4fc0a into develop Aug 6, 2026
13 checks passed
ajianaz added a commit that referenced this pull request Aug 13, 2026
…ard (#911)

#902: Add before/after RFC3339 fields to RecallRequest. Post-filter
results by created_at in both unified and memory-only recall paths.
Invalid timestamps return 400.

#903: Cap limit at MAX_LIMIT (100) to prevent DoS via unbounded queries.

#907: Reject empty/whitespace query strings with 400 instead of returning
misleading top-N results.

Co-authored-by: ajianaz <[email protected]>
@ajianaz
ajianaz deleted the fix/http-temporal-limits-query-guard branch August 13, 2026 01:52
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: HTTP API /recall ignores before/after temporal filter parameters

2 participants