Skip to content

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

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

Merged
merged 3 commits into from
Jul 21, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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