Skip to content

fix(atlas-search): reject whitespace-only query on GET /v1/cache/inspect (#6937) - #6938

Merged
dezren39 merged 1 commit into
mainfrom
creator-b/6937-inspect-empty-query
Nov 7, 2026
Merged

dezren39 merged 1 commit into
mainfrom
creator-b/6937-inspect-empty-query

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #6937.

GET /v1/cache/inspect guarded only the raw query parameter (if (!q)), then normalized and never re-checked — a whitespace-only query normalized to "", was keyed, and its Durable Object was queried, returning 200. POST /v1/search already rejects the same input with 400 "query must not be empty".

Change (pkgs/atlas-search/worker/src/index.ts, +4 lines): after normalizeQuery, return the search route's 400 when the normalized query is empty, before keying or any Durable Object call.

Test (test/worker.test.ts, +17 lines): one regression test pinning both routes — whitespace-only search → 400, whitespace-only inspect → 400 with message "query must not be empty", and the service embed/search counters unmoved.

Verification (laptop, this branch):

  • Real-module probe (bun, stub QUERY_CACHE): pre-fix inspect ws-only → 200, DO called once; post-fix → 400, 0 DO calls; real-query inspect → 200 (1 DO call) and missing-query → 400 unchanged.
  • npm test in pkgs/atlas-search/worker: 13/13 passed (3 files, incl. the new test).
  • npm run typecheck (tsc --noEmit): clean.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Cache inspection now returns a clear error for queries that contain only whitespace, consistent with search behavior.

@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 18:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T18:38:00.620753Z 85c44a6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39 dezren39 added kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job app/atlas-search pkgs/atlas-search (Atlas search service + atlas-embed) priority/low Nice to have; do when convenient labels Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The cache-inspection route now rejects queries that are empty after normalization. A worker test checks that both search routes return 400 for whitespace-only queries and do not trigger embedding or search calls.

Changes: Empty query validation

Layer / File(s) Summary
Validate normalized queries
pkgs/atlas-search/worker/src/index.ts, pkgs/atlas-search/worker/test/worker.test.ts
The inspect route returns 400 before key generation or Durable Object access when the normalized query is empty. The test checks both routes’ responses and verifies that embedding and search calls do not increase.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Merge Risk: Minimal · up to 85c44

Whitespace-only inspection queries are rejected before Durable Object access. Additional regression assertions would strengthen coverage, but no new merge-blocking behavior is established. The existing empty-parameter error-message discrepancy remains a follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app/atlas-search pkgs/atlas-search (Atlas search service + atlas-embed) kind/bug Something isn't working (prefixed form of the classic bug label) priority/low Nice to have; do when convenient source/creator Filed by the new-issue-creator job

Projects

None yet

1 participant