@Override
    public Output run(RunContext runContext) throws Exception {
        String taskSpec = runContext.render(this.spec);
        try {
            Task task = OBJECT_MAPPER.readValue(taskSpec, Task.class);
            if (task instanceof TemplatedTask) {
                throw new IllegalArgumentException("The templated task cannot be of type 'io.kestra.plugin.core.templating.TemplatedTask'");
            }
            if (task instanceof RunnableTask<?> runnableTask) {
                return runnableTask.run(runContext);
            }
            throw new IllegalArgumentException("The templated task must be a runnable task");
        } catch (JsonProcessingException e) {
            throw new IllegalVariableEvaluationException(e);
        }
    }
@Test
    void templatedTemplated() {
        RunContext runContext = runContextFactory.of();
        TemplatedTask templatedTask = TemplatedTask.builder()
            .id("template")
            .type(TemplatedTask.class.getName())
            .spec("""
                type: io.kestra.plugin.core.templating.TemplatedTask
                spec: whatever""")
            .build();

        var exception = assertThrows(IllegalArgumentException.class, () -> templatedTask.run(runContext));
        assertThat(exception.getMessage(), is("The templated task cannot be of type 'io.kestra.plugin.core.templating.TemplatedTask'"));
    }