Skip to content

fix(ai): coerce query_workspace limit to int (str limit crashed the backend)#1280

Merged
ocervell merged 1 commit into
ai-resiliencyfrom
fix/ai-query-limit-coerce
Jul 5, 2026
Merged

fix(ai): coerce query_workspace limit to int (str limit crashed the backend)#1280
ocervell merged 1 commit into
ai-resiliencyfrom
fix/ai-query-limit-coerce

Conversation

@ocervell

@ocervell ocervell commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Bug

🟢Query({'_type': 'ip', 'host': 'cachyos.local'}) -> failed results (limit: 10)
[ERR] ai TypeError: '>=' not supported between instances of 'int' and 'str'
  File ".../query/json.py", line 182, in _execute_search
    if limit and len(matched) >= limit:

The model sent query_workspace's limit as a string ("10"); it reached the backend and broke the >= comparison. Same "model stringifies args" class as #1275, but coerce_stringified_args only handles object/array params — not scalar ints like limit.

Fix

Coerce limit to int in _handle_query; bad/None values fall back to the default (100).

Tests

Stringified "10"10 reaches the backend; a non-numeric limit falls back to 100. test_ai_actions.py 99 passed; the original crash reproduces as resolved.

Targets ai-resiliency (#1241).

🤖 Generated with Claude Code

… backend)

Some models send the `limit` arg as a string ("10"); a str limit reached the
query backend and raised `TypeError: '>=' not supported between instances of int
and str` (json.py: `len(matched) >= limit`). Coerce `limit` to int in
_handle_query, falling back to the default (100) for bad/None values. Same class
as the stringified-arg coercion (#1275), which only handles object/array params.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NNjPggRSVZ2xnLb7ZxWP5H
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6eb7371c-028d-473b-a3c9-00b63e7eccc4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ai-query-limit-coerce

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.

@ocervell ocervell merged commit 5a2d6c1 into ai-resiliency Jul 5, 2026
1 check was pending
@ocervell ocervell deleted the fix/ai-query-limit-coerce branch July 5, 2026 19:22
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.

1 participant