fix(cli): stop workspace-cli from silently stripping quotes on string args - #983
Merged
taylorwilsdon merged 4 commits intoAug 2, 2026
Merged
Conversation
workspace-cli _call_tool ran json.loads on every key=value value and only fell back to the raw string on JSONDecodeError. A quoted value like query='"exact phrase"' is itself valid JSON, so json.loads stripped the quotes and the server received an unquoted string, breaking Gmail phrase queries with no error. Add _coerce_cli_value(), which only JSON-decodes values that look like JSON (containers, true/false/null, numbers) and returns everything else raw. page_size=3 and values=[["a"]] still coerce; quoted phrases survive verbatim. Adds unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe CLI preserves string values during selective JSON coercion. Uvicorn explicitly uses ChangesCLI coercion
WebSocket runtime configuration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…into fix/cli-quoted-value-parsing
Replace the looks-like-JSON pre-check (number regex, literal set, empty-string special case) with the rule it was approximating: decode as JSON, and keep the raw text whenever the result is a string. Same behavior, no regex, and the quote-stripping fix is expressed directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a bug where
workspace-clisilently strips surrounding quotes from string arguments._call_toolincore/cli.pyparses eachkey=valueargument by runningjson.loads(v)and only falling back to the raw string onJSONDecodeError:A quoted string value is itself valid JSON, so the surrounding quotes are silently stripped. For a Gmail exact-phrase query:
workspace-cli call search_gmail_messages query='"exact phrase"'json.loads('"exact phrase"')returnsexact phrase(unquoted), so the server runs an unquoted query. There is no error — it just silently returns different/empty results, which is easy to misread as "no matches."Fix: add
_coerce_cli_value(), which only attemptsjson.loadswhen the value actually looks like JSON (empty →""; first non-space char is{/[; exactlytrue/false/null; or a numeric literal). Everything else is returned unchanged as a raw string, so quotes and other characters survive verbatim.page_size=3still coerces tointandvalues=[["a"]]still parses to a list.Type of Change
Testing
Added
tests/core/test_cli_value_coercion.py(15 cases): strings preserved verbatim (including quoted phrases and date-like values) and JSON scalars/containers that should still be coerced. Manually verifiedquery='"grow therapy"'now reaches the server with the quotes intact.Checklist
Additional Notes
Scope is intentionally minimal — one helper plus a two-line change at the call site, no behavior change for existing JSON-typed args.
ruff checkis clean on the changed files and the new test module.Summary by CodeRabbit
Bug Fixes
Tests