fix: improve SSE parsing error visibility and propagation#28
Closed
fix: improve SSE parsing error visibility and propagation#28
Conversation
Greptile OverviewGreptile SummaryThis PR implements two improvements to the Cortex codebase: enhanced SSE parsing error handling and centralized timeout constants. SSE Error Handling
Timeout Centralization
Impact
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/cortex-engine/src/client/cortex.rs | Upgraded SSE parsing error logging from debug to warning level and propagated errors to callers |
| src/cortex-common/src/timeout.rs | New module centralizing timeout constants with comprehensive documentation and tests |
| src/cortex-engine/src/tools/handlers/batch.rs | Removed local constant in favor of centralized timeout value from cortex-common |
| src/cortex-exec/src/runner.rs | Replaced local timeout constants with centralized values from cortex-common |
Sequence Diagram
sequenceDiagram
participant Client as CortexClient
participant SSE as SSE Stream
participant Parser as JSON Parser
participant Channel as Response Channel
participant Caller as Caller/Consumer
SSE->>Client: SSE Event (data)
Client->>Parser: serde_json::from_str(event.data)
alt Parsing Success
Parser-->>Client: Ok(CortexResponseEvent)
Client->>Client: Match event type
Client->>Client: Create ResponseEvent
Client->>Channel: tx.send(Ok(ResponseEvent))
Channel-->>Caller: Deliver event
else Parsing Failure
Parser-->>Client: Err(e)
Client->>Client: Create data_preview (first 100 chars)
Client->>Client: tracing::warn!(error, data_preview)
Client->>Client: Format error message
Client->>Channel: tx.send(Ok(ResponseEvent::Error))
Channel-->>Caller: Deliver parsing error
end
Note over Client,Caller: Before: Errors logged at debug level and ignored<br/>After: Errors logged at warning level and propagated
Contributor
Author
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.
Summary
This PR improves error handling for SSE (Server-Sent Events) parsing in the Cortex client. Previously, parsing errors were logged at debug level and silently ignored. Now, these errors are logged at warning level for visibility and propagated to callers.
Changes
ResponseEvent::Errorto callers so they can handle parsing failuresVerification
Note: There are pre-existing compilation errors in batch.rs and unified_executor.rs (missing
tool_timeout_secsfield) that are unrelated to this PR.