- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Fix JSON repair handling for null payloads #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| WalkthroughThe JSON repair flow now returns a JsonRepairResult object across middleware, streaming processor, and service layers. Logic, metrics, and logging were updated to branch on result.success and use result.content. Tests were revised and expanded, including explicit handling of "null" payloads and adjustments to mocks and assertions. Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant Client
  participant Middleware
  participant JsonRepairService
  Client->>Middleware: process(response)
  Middleware->>JsonRepairService: repair_and_validate_json(payload, schema?, strict)
  JsonRepairService-->>Middleware: JsonRepairResult{ success, content }
  alt success == true
    Middleware->>Middleware: replace response.content with result.content
    Middleware->>Metrics: emit json_repair.non_streaming.{suffix}
    Middleware-->>Client: response (repaired)
  else success == false
    Middleware->>Metrics: emit json_repair.non_streaming.{suffix}
    Middleware-->>Client: response (original)
  end
sequenceDiagram
  autonumber
  participant StreamSrc as Stream Source
  participant Processor as JsonRepairProcessor
  participant Service as JsonRepairService
  participant Downstream
  StreamSrc->>Processor: chunk data
  Processor->>Processor: buffer/parse blocks
  Processor->>Service: repair_and_validate_json(block, schema?, strict?)
  Service-->>Processor: JsonRepairResult{ success, content }
  alt success
    Processor->>Downstream: emit result.content
  else failure
    Processor->>Downstream: emit original buffer
  end
  Note over Processor: On final flush, same success/failure handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
 🧰 Additional context used📓 Path-based instructions (2)**/*.py📄 CodeRabbit inference engine (AGENTS.md) 
 Files: 
 src/**/*.py📄 CodeRabbit inference engine (AGENTS.md) 
 Files: 
 🧬 Code graph analysis (5)tests/unit/core/services/test_json_repair_middleware.py (2)
 src/core/services/streaming/json_repair_processor.py (3)
 tests/unit/json_repair_processor_test.py (2)
 tests/unit/core/services/test_json_repair_service.py (2)
 src/core/app/middleware/json_repair_middleware.py (2)
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
 🔇 Additional comments (12)
 Comment  | 
| Codecov Report❌ Patch coverage is  
 📢 Thoughts on this report? Let us know! | 
Summary
nullare treated as successful repairsnullpayloads and the revised repair contractTesting
https://chatgpt.com/codex/tasks/task_e_68ec26ffb7448333ace9a74c4ba180a1
Summary by CodeRabbit
Bug Fixes
Refactor
Tests