Repository: kestra-io/kestra
File: webserver/src/main/java/io/kestra/webserver/controllers/api/FlowController.java (Java)

Code before:

        return this.bulkUpdateOrCreate(namespace, genericFlows, delete, false);
    }

    @ExecuteOn(TaskExecutors.IO)
    @Post(uri = "{namespace}", consumes = MediaType.MULTIPART_FORM_DATA)
    @Operation(
        tags = {"Flows"},
        summary = "Update a complete namespace from yaml source",
        description = "All flows will be created / updated for this namespace.\n" +
            "Existing flows missing from `flows` will be deleted if the query delete is `true`"
    )
    public List<FlowInterface> updateFlowsInNamespace(
        @Parameter(description = "The flow namespace") @PathVariable String namespace,
        @RequestBody(description = "A list of flow files") @Part("flows") Publisher<CompletedFileUpload> flowsPublisher,
        @Parameter(description = "If namespace of all provided flows should be overridden") @QueryValue(defaultValue = "false") Boolean override,
        @Parameter(description = "If missing flows should be deleted") @QueryValue(defaultValue = "true") Boolean delete
    ) throws ConstraintViolationException, IOException {
        List<CompletedFileUpload> flows = Flux.from(flowsPublisher)
            .collectList()
            .blockOptional()
            .orElse(Collections.emptyList());

        List<GenericFlow> genericFlows = new ArrayList<>();
        for (CompletedFileUpload flow : flows) {
            String source = new String(flow.getBytes(), Charset.defaultCharset()).trim();
            if (override) {
                source = source.replaceFirst("(?m)^namespace:.+", "namespace: " + namespace);
            }

            genericFlows.add(parseFlowSource(source));
        }

        return this.bulkUpdateOrCreate(namespace, genericFlows, delete, false);
    }

    /**
     * @deprecated use {@link #updateFlowsInNamespace(String, String, Boolean)} instead
     */
    @ExecuteOn(TaskExecutors.IO)
    @Post(uri = "{namespace}")
    @Operation(
        tags = {"Flows"},
        summary = "Update a complete namespace from json object",
        description = "All flow will be created / updated for this namespace.\n" +
                      "Flow that already created but not in `flows` will be deleted if the query delete is `true`",
        deprecated = true,
        hidden = true
    )
    @Deprecated(forRemoval = true, since = "0.18")
    @Hidden // we hide it otherwise this is the one that will be included in the OpenAPI spec instead of the YAML one.

Review comment (suggestion):
```suggestion
            String source = new String(flow.getBytes()).trim();
```

We're storing UTF-8 in the database

Code after:
        return this.bulkUpdateOrCreate(namespace, genericFlows, delete, false);
    }

    @ExecuteOn(TaskExecutors.IO)
    @Post(uri = "{namespace}", consumes = MediaType.MULTIPART_FORM_DATA)
    @Operation(
        tags = {"Flows"},
        summary = "Update a complete namespace from yaml source",
        description = "All flows will be created / updated for this namespace.\n" +
            "Existing flows missing from `flows` will be deleted if the query delete is `true`"
    )
    public List<FlowInterface> updateFlowsInNamespace(
        @Parameter(description = "The flow namespace") @PathVariable String namespace,
        @RequestBody(description = "A list of flow files") @Part("flows") Publisher<CompletedFileUpload> flowsPublisher,
        @Parameter(description = "If namespace of all provided flows should be overridden") @QueryValue(defaultValue = "false") Boolean override,
        @Parameter(description = "If missing flows should be deleted") @QueryValue(defaultValue = "true") Boolean delete
    ) throws ConstraintViolationException, IOException {
        List<CompletedFileUpload> flowFiles = Flux.from(flowsPublisher)
            .collectList()
            .blockOptional()
            .orElse(Collections.emptyList());

        List<GenericFlow> genericFlows = new ArrayList<>();
        for (CompletedFileUpload flowFile : flowFiles) {
            String source = new String(flowFile.getBytes()).trim();
            if (override) {
                source = source.replaceFirst("(?m)^namespace:.+", "namespace: " + namespace);
            }

            genericFlows.add(parseFlowSource(source));
        }

        return this.bulkUpdateOrCreate(namespace, genericFlows, delete, false);
    }

    /**
     * @deprecated use {@link #updateFlowsInNamespace(String, String, Boolean)} instead
     */
    @ExecuteOn(TaskExecutors.IO)
    @Post(uri = "{namespace}")
    @Operation(
        tags = {"Flows"},
        summary = "Update a complete namespace from json object",
        description = "All flow will be created / updated for this namespace.\n" +
                      "Flow that already created but not in `flows` will be deleted if the query delete is `true`",
        deprecated = true,
        hidden = true
    )
    @Deprecated(forRemoval = true, since = "0.18")
    @Hidden // we hide it otherwise this is the one that will be included in the OpenAPI spec instead of the YAML one.
    public List<Flow> updateFlowsInNamespaceFromJson(