From 2cf9104a31584cb0e456db95cbf2112eef9863e8 Mon Sep 17 00:00:00 2001 From: YannC <37600690+Skraye@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:04:05 +0200 Subject: [PATCH] fix(webserver): missing params in file paths (#4966) close #4958 --- .../webserver/controllers/api/ExecutionController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/api/ExecutionController.java b/webserver/src/main/java/io/kestra/webserver/controllers/api/ExecutionController.java index 9ae3c28391..9e61d405eb 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/api/ExecutionController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/api/ExecutionController.java @@ -654,7 +654,7 @@ public HttpResponse file( @Parameter(description = "The execution id") @PathVariable String executionId, @Parameter(description = "The internal storage uri") @QueryValue URI path ) throws IOException, URISyntaxException { - HttpResponse httpResponse = this.validateFile(executionId, path, "/api/v1/executions/{executionId}/file?path=" + path); + HttpResponse httpResponse = this.validateFile(executionId, path, "/api/v1/" + this.getTenant() + "executions/{executionId}/file?path=" + path); if (httpResponse != null) { return httpResponse; } @@ -672,7 +672,7 @@ public HttpResponse filesize( @Parameter(description = "The execution id") @PathVariable String executionId, @Parameter(description = "The internal storage uri") @QueryValue URI path ) throws IOException { - HttpResponse httpResponse = this.validateFile(executionId, path, "/api/v1/executions/{executionId}/file/metas?path=" + path); + HttpResponse httpResponse = this.validateFile(executionId, path, "/api/v1/" + this.getTenant() + "executions/{executionId}/file/metas?path=" + path); if (httpResponse != null) { return httpResponse; } @@ -1296,7 +1296,7 @@ public HttpResponse filePreview( @Parameter(description = "The max row returns") @QueryValue @Nullable Integer maxRows, @Parameter(description = "The file encoding as Java charset name. Defaults to UTF-8", example = "ISO-8859-1") @QueryValue(defaultValue = "UTF-8") String encoding ) throws IOException { - this.validateFile(executionId, path, "/api/v1/executions/{executionId}/file?path=" + path); + this.validateFile(executionId, path, "/api/v1/" + this.getTenant() + "executions/{executionId}/file?path=" + path); String extension = FilenameUtils.getExtension(path.toString()); Optional charset; @@ -1495,4 +1495,8 @@ public List getFlowsByNamespace( return flowRepository.findByNamespaceExecutable(tenantService.resolveTenant(), namespace); } + public String getTenant() { + return tenantService.resolveTenant() != null ? tenantService.resolveTenant() + "/" : ""; + } + }