@Operation(summary = "get task log", description = "Get a task log")
    @GetMapping("/tasks/{id}/log")
    public SseEmitter log(@PathVariable Long id, @PathVariable Long clusterId) {
        // Default timeout to 30 minutes
        SseEmitter emitter = new SseEmitter(30 * 60 * 1000L);

        Flux<String> flux =
                Flux.create(sink -> taskLogService.registerSink(id, sink), FluxSink.OverflowStrategy.BUFFER);
        flux.subscribe(
                s -> {
                    try {
                        emitter.send(s);
                    } catch (Exception e) {
                        emitter.completeWithError(e);
                    }
                },
                Throwable::printStackTrace,
                emitter::complete);

        emitter.onTimeout(emitter::complete);
        return emitter;
    }
@Test
    void logHandlesExceptionDuringEmission() {
        Long taskId = 1L;
        Long clusterId = 1L;
        doAnswer(invocation -> {
                    FluxSink<String> sink = invocation.getArgument(1);
                    sink.error(new RuntimeException("Test exception"));
                    return null;
                })
                .when(taskLogService)
                .registerSink(eq(taskId), any());

        SseEmitter emitter = sseController.log(taskId, clusterId);

        assertNotNull(emitter);
    }