Skip to content

Manifest handling: default charset, pushManifestV3 error handling, leftover temp files #1411

Open

Description

@ZPascal

While reviewing #1410 I came across a few older problems around manifest handling. #1410 didn't cause them, so I'm putting them here instead of holding up that PR. All three exist on both main and 5.x.x.

1. Manifest YAML is written with the platform default charset

ApplicationManifestUtils.write(OutputStream, ...) (line 113) and ApplicationManifestUtilsV3.write(OutputStream, ...) (line 111) both do:

try (Writer writer = new OutputStreamWriter(out)) {

There's no charset, so it uses whatever the JVM default is. CAPI expects UTF-8. On Java 8 to 17 on Windows the default is usually cp1252, so any non-ASCII text in env values, labels, routes and so on gets mangled or turned into ?. pushManifestV3 uses this method to build the apply_manifest body, so this affects real pushes, not just files on disk.

Suggested fix, in both classes:

try (Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {

2. pushManifestV3 throws instead of returning an error Mono

In DefaultApplications.pushManifestV3 the manifest is serialized right when the method is called, before anyone subscribes, and a failure is thrown as a plain RuntimeException:

byte[] manifestSerialized;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
    ApplicationManifestUtilsV3.write(baos, request.getManifest());
    manifestSerialized = baos.toByteArray();
} catch (IOException e) {
    throw new RuntimeException("Could not serialize manifest", e);
}
return Mono.zip(this.cloudFoundryClient, this.spaceId)...

So callers who handle errors with onErrorResume or doOnError never see this one. It just blows up while they're building the chain. It would be more consistent to do the work lazily:

Mono<byte[]> manifestSerialized =
        Mono.fromCallable(
                () -> {
                    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                        ApplicationManifestUtilsV3.write(baos, request.getManifest());
                        return baos.toByteArray();
                    }
                });

and then use that in the existing chain (for example with Mono.zip(this.cloudFoundryClient, this.spaceId, manifestSerialized)).

3. Tests leave manifest files behind in the temp directory

ApplicationManifestUtilsTest (line 631) and ApplicationManifestUtilsV3Test (line 152) create files with Files.createTempFile("test-manifest-", ".yml") and never delete them. Every test run leaves more of them in /tmp, and once #1410 is merged some of them will contain docker credentials (dummy ones, but still).

Using JUnit's @TempDir takes care of this:

@TempDir Path tempDir;

private void assertSerializeDeserialize(ManifestV3 manifest) throws IOException {
    Path file = tempDir.resolve("test-manifest.yml");
    ApplicationManifestUtilsV3.write(file, manifest);
    ManifestV3 read = ApplicationManifestUtilsV3.read(file);

    assertEquals(manifest, read);
}

I'm happy to open a PR for these if nobody objects.

Activity

  1. added a commit that references this issue on Nov 23, 2026
    cab275e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions