Skip to content

Conversation

cdavernas
Copy link
Member

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it:

  • Fixes both the ClusterResourceController and NamespacedResourceController by ensuring that SSE-based actions do not set the response's status code after streaming

…esourceController` by ensuring that SSE-based actions do not set the response's status code after streaming

Fixes #508

Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a fundamental issue with Server-Sent Events (SSE) implementation in both ClusterResourceController and NamespacedResourceController by preventing the setting of HTTP status codes after streaming has begun. The changes ensure proper SSE streaming behavior while maintaining error handling capabilities.

  • Modified SSE action methods to return Task instead of IActionResult to avoid status code conflicts
  • Refactored error handling to write responses directly to the HTTP response stream
  • Consolidated JSON serialization dependency in the base ResourceController class

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Usings.cs Added System.Net.Mime namespace for content type constants
ResourceController.cs Added JSON serializer dependency and helper methods for direct response writing
NamespacedResourceController.cs Updated SSE methods to avoid status code setting after streaming
ClusterResourceController.cs Updated SSE methods to avoid status code setting after streaming

cdavernas and others added 2 commits July 21, 2025 11:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
@cdavernas cdavernas merged commit b92f584 into main Jul 21, 2025
2 checks passed
@cdavernas cdavernas deleted the fix-sse-streaming branch July 21, 2025 09:20
@cdavernas cdavernas added priority: high Indicates a high priority issue app: api Concerns the API weight: 1 An issue that has a very low development impact type: fix labels Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: api Concerns the API priority: high Indicates a high priority issue type: fix weight: 1 An issue that has a very low development impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate instances and StatusCode cannot be set because the response has already started
1 participant