Repository navigation
fix(api): decode complete suggested question arrays - #44916
Conversation
Pyrefly Type Coverage
|
|
CI follow-up: the API jobs stopped before test collection at The lock is The autofix job identifies exactly one inherited metadata difference in Update: the official autofix.ci bot has now appended commit |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #44916 +/- ##
==========================================
- Coverage 89.52% 89.52% -0.01%
==========================================
Files 6009 6009
Lines 376773 376772 -1
Branches 76234 76234
==========================================
- Hits 337311 337310 -1
Misses 33462 33462
Partials 6000 6000
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Fixes #44914.
A valid suggested-questions response such as
["How do I use arr[0]?", "What should I try next?"]currently returns no questions. The non-greedy array regex stops at the closing bracket inside the first string, so JSON decoding receives a truncated payload.Use
JSONDecoder.raw_decodefrom the first opening bracket. The decoder determines the array boundary while respecting quoted brackets, escaped quotes, and nested values. Keep the existing prose/code-fence tolerance, string-item filtering, first-array selection, and malformed-input fallback.Move the parser beside its single production caller in
services/, update that caller, and relocate the existing pure parser tests to the matching service test module. This follows the migration-only policy forapi/corewithout adding a forwarding wrapper.Validation
git diff --check: passed.Command from the repository root, using Python 3.13.7 and an isolated dependency environment:
The hook reused the prepared dependency environment without syncing the entire backend. Full service import was attempted but the local SQLAlchemy 2.1.6 installation rejects an existing model's simultaneous
defaultandinsert_defaultarguments. The complete API suite, provider invocation, and deployed UI were not run. These tests exercise the actual parser used by the shared generation service and make no live model calls.Reasoning-tag stripping is outside this fix; #34652, #41881, and #42192 address that separate behavior and retain the array-boundary regex.
AI assistance was used for investigation, implementation, and review.
Checklist
make lint && make type-checkcommands (scoped checks were run instead).From Codex