This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new f15ae7b262 hop export writes a Mermaid diagram when the format has no 
exporter, … (#9388)
f15ae7b262 is described below

commit f15ae7b262fbdef44fc0817a795ec8e0689d8708
Author: Bart Maertens <[email protected]>
AuthorDate: Thu Nov 12 11:19:44 2026 +0100

    hop export writes a Mermaid diagram when the format has no exporter, … 
(#9388)
    
    * hop export writes a Mermaid diagram when the format has no exporter, and 
ends with exit code 0, fixes #9383
    
    * Address review: GUI exporters without a format, -o extension lookup, skip 
unsupported files in folder export, issue #9383
---
 .gitignore                                         |   1 +
 .../hop/core/diagram/DiagramExportService.java     |  96 +++++--
 .../hop/core/diagram/DiagramExportServiceTest.java |  71 +++++
 .../ROOT/pages/plugin-types/diagram-exporters.adoc |  12 +-
 .../modules/ROOT/pages/hop-tools/hop-export.adoc   |   7 +-
 .../hop/diagram/command/DiagramExportCommand.java  | 125 +++++++--
 .../diagram/command/DiagramExportCommandTest.java  | 195 ++++++++++++++
 integration-tests/export/dev-env-config.json       |   9 +
 integration-tests/export/hop-config.json           | 290 +++++++++++++++++++++
 .../export/main-0001-export-known-formats.hwf      | 183 +++++++++++++
 .../main-0002-export-unknown-format-fails.hwf      | 204 +++++++++++++++
 .../metadata/pipeline-run-configuration/local.json |  17 ++
 .../metadata/workflow-run-configuration/local.json |   9 +
 integration-tests/export/project-config.json       |  13 +
 integration-tests/export/subject/fast-pipeline.hpl |  69 +++++
 integration-tests/export/subject/fast-workflow.hwf |  74 ++++++
 .../ui/hopgui/dialog/DiagramExportDialogModel.java |   7 +-
 .../dialog/DiagramExportDialogModelTest.java       |  44 ++++
 18 files changed, 1369 insertions(+), 57 deletions(-)

diff --git a/.gitignore b/.gitignore
index 27b47efd29..b27366ba76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,7 @@ integration-tests/pgp/output/
 integration-tests/lint/output/
 # hop-import writes each test's imported project, and 0005 its hop-run log, 
under output/
 integration-tests/import/output/
+integration-tests/export/output/
 integration-tests/spreadsheet/files/sample-file-append.xlsx
 integration-tests/spreadsheet/files/sample-file-append-test.xlsx
 integration-tests/spark-native/output
diff --git 
a/core/src/main/java/org/apache/hop/core/diagram/DiagramExportService.java 
b/core/src/main/java/org/apache/hop/core/diagram/DiagramExportService.java
index f019a7bb93..8345d9b903 100644
--- a/core/src/main/java/org/apache/hop/core/diagram/DiagramExportService.java
+++ b/core/src/main/java/org/apache/hop/core/diagram/DiagramExportService.java
@@ -19,6 +19,8 @@ package org.apache.hop.core.diagram;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hop.core.exception.HopException;
@@ -98,13 +100,29 @@ public class DiagramExportService {
     if (formatId == null) {
       return null;
     }
-    for (IDiagramExporter<?> exporter : findExportersForSubject(subject)) {
-      if (exporter.getFormat() != null
-          && exporter.getFormat().getId().equalsIgnoreCase(formatId.trim())) {
-        return exporter;
-      }
-      if (exporter.getFileExtension() != null
-          && exporter.getFileExtension().equalsIgnoreCase(formatId.trim())) {
+    return findExporterForFormat(findExportersForSubject(subject), formatId);
+  }
+
+  /**
+   * Finds the first of the given exporters that writes a format, matched in 
upper or lower case on
+   * the format id ({@code MERMAID}), the file extension ({@code mmd}) or the 
exporter id ({@code
+   * pipeline-mermaid}). The exporter id is what the GUI sends for an exporter 
without a format.
+   *
+   * @param exporters the exporters to look in, for example those for one 
subject
+   * @param format the format id, file extension or exporter id
+   * @return the matching exporter, or {@code null} when none matches
+   */
+  public static IDiagramExporter<?> findExporterForFormat(
+      List<IDiagramExporter<?>> exporters, String format) {
+    if (exporters == null || StringUtils.isBlank(format)) {
+      return null;
+    }
+    String wanted = format.trim();
+    for (IDiagramExporter<?> exporter : exporters) {
+      if ((exporter.getFormat() != null
+              && StringUtils.equalsIgnoreCase(wanted, 
exporter.getFormat().getId()))
+          || StringUtils.equalsIgnoreCase(wanted, exporter.getFileExtension())
+          || StringUtils.equalsIgnoreCase(wanted, exporter.getId())) {
         return exporter;
       }
     }
@@ -144,27 +162,63 @@ public class DiagramExportService {
     if (options == null) {
       throw new HopException("No export options provided");
     }
-    IDiagramExporter exporter = null;
-    if (StringUtils.isNotEmpty(options.getFormat())) {
-      exporter = findExporter(subject, options.getFormat());
-    }
-    if (exporter == null) {
-      List<IDiagramExporter<?>> available = findExportersForSubject(subject);
-      if (!available.isEmpty()) {
-        exporter = available.get(0);
+    List<IDiagramExporter<?>> available = findExportersForSubject(subject);
+    IDiagramExporter exporter;
+    if (StringUtils.isNotBlank(options.getFormat())) {
+      // A format that was asked for must be honoured: never write another 
format under its name.
+      exporter = findExporterForFormat(available, options.getFormat());
+      if (exporter == null) {
+        throw new HopException(
+            "No diagram exporter for format '"
+                + options.getFormat().trim()
+                + "' supports "
+                + subject.getClass().getName()
+                + ". Available formats: "
+                + describeFormats(available));
       }
-    }
-    if (exporter == null) {
+    } else if (!available.isEmpty()) {
+      exporter = available.get(0);
+    } else {
       throw new HopException(
-          "No diagram exporter found supporting subject "
-              + subject.getClass().getName()
-              + (options.getFormat() != null ? " with format " + 
options.getFormat() : ""));
+          "No diagram exporter found supporting subject " + 
subject.getClass().getName());
     }
     return exporter.export(subject, options, context);
   }
 
+  /**
+   * Describes the formats of the given exporters, for example {@code MERMAID 
(.mmd), SVG (.svg)}.
+   *
+   * @param exporters the exporters to describe
+   * @return the format ids with their file extension, sorted, or {@code none} 
for an empty list
+   */
+  public static String describeFormats(List<IDiagramExporter<?>> exporters) {
+    Set<String> formats = new TreeSet<>();
+    for (IDiagramExporter<?> exporter : exporters) {
+      if (exporter.getFormat() == null) {
+        continue;
+      }
+      String extension = exporter.getFileExtension();
+      formats.add(
+          exporter.getFormat().getId()
+              + (StringUtils.isNotBlank(extension) ? " (." + extension + ")" : 
""));
+    }
+    return formats.isEmpty() ? "none" : String.join(", ", formats);
+  }
+
   public DiagramExportResult exportFile(
       String filename, DiagramExportOptions options, IExportContext context) 
throws HopException {
+    return export(loadSubject(filename, context), options, context);
+  }
+
+  /**
+   * Loads the subject (pipeline, workflow, ...) of a file with the subject 
loader for that file.
+   *
+   * @param filename the file to load
+   * @param context the context with the metadata provider and variables to 
load it with
+   * @return the subject, never {@code null}
+   * @throws HopException when no loader supports the file or the file can't 
be loaded
+   */
+  public Object loadSubject(String filename, IExportContext context) throws 
HopException {
     if (StringUtils.isBlank(filename)) {
       throw new HopException("No filename provided to export");
     }
@@ -180,6 +234,6 @@ public class DiagramExportService {
     if (subject == null) {
       throw new HopException("Failed to load diagram subject from file: " + 
filename);
     }
-    return export(subject, options, context);
+    return subject;
   }
 }
diff --git 
a/core/src/test/java/org/apache/hop/core/diagram/DiagramExportServiceTest.java 
b/core/src/test/java/org/apache/hop/core/diagram/DiagramExportServiceTest.java
index 76c0e529a6..5b86f47a1a 100644
--- 
a/core/src/test/java/org/apache/hop/core/diagram/DiagramExportServiceTest.java
+++ 
b/core/src/test/java/org/apache/hop/core/diagram/DiagramExportServiceTest.java
@@ -20,6 +20,8 @@ package org.apache.hop.core.diagram;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
@@ -58,6 +60,22 @@ class DiagramExportServiceTest {
     }
   }
 
+  /** An exporter without an annotation, a format or a file extension. */
+  static class NoFormatExporter extends BaseDiagramExporter<TestSubject> {
+    NoFormatExporter(String id, DiagramExportFormat format) {
+      this.id = id;
+      this.name = "No Format";
+      this.format = format;
+      this.supportedSubjectTypes = new Class<?>[] {TestSubject.class};
+    }
+
+    @Override
+    public DiagramExportResult export(
+        TestSubject subject, DiagramExportOptions options, IExportContext 
context) {
+      return DiagramExportResult.success(options.getTargetFilename(), "plain", 
"text/plain");
+    }
+  }
+
   @BeforeEach
   void setUp() {
     service = DiagramExportService.getInstance();
@@ -103,6 +121,59 @@ class DiagramExportServiceTest {
     assertEquals("text/vnd.mermaid", result.getMimeType());
   }
 
+  @Test
+  void testExportWithUnknownFormatFails() {
+    TestSubject subject = new TestSubject();
+    IExportContext context =
+        new ExportContext(new Variables(), null, null, 
IExportContext.ExportEnvironment.TEST);
+
+    for (String format : List.of("PDF", "foo")) {
+      DiagramExportOptions options = new DiagramExportOptions(null, format);
+      HopException e =
+          assertThrows(HopException.class, () -> service.export(subject, 
options, context));
+      assertTrue(e.getMessage().contains("'" + format + "'"), e.getMessage());
+      assertTrue(e.getMessage().contains("MERMAID (.mmd)"), e.getMessage());
+    }
+  }
+
+  @Test
+  void testExportWithoutFormatUsesFirstExporter() throws Exception {
+    TestSubject subject = new TestSubject();
+    IExportContext context =
+        new ExportContext(new Variables(), null, null, 
IExportContext.ExportEnvironment.TEST);
+
+    DiagramExportResult result =
+        service.export(subject, new DiagramExportOptions(null, null), context);
+    assertTrue(result.isSuccess());
+    assertEquals("text/vnd.mermaid", result.getMimeType());
+  }
+
+  /** The GUI sends the exporter id for an exporter without a format. */
+  @Test
+  void testExporterWithoutFormatIsFoundById() throws Exception {
+    NoFormatExporter noFormat = new NoFormatExporter("no-format", null);
+    NoFormatExporter nullFormatId =
+        new NoFormatExporter("null-format-id", new DiagramExportFormat(null, 
null, null, null));
+    service.registerStaticExporter(nullFormatId);
+    service.registerStaticExporter(noFormat);
+    try {
+      TestSubject subject = new TestSubject();
+      IExportContext context =
+          new ExportContext(new Variables(), null, null, 
IExportContext.ExportEnvironment.TEST);
+
+      DiagramExportResult result =
+          service.export(subject, new DiagramExportOptions(null, "no-format"), 
context);
+      assertEquals("plain", result.getContent());
+
+      // A format id that is null does not stop the lookup of the other 
exporters
+      assertEquals("test-exporter", service.findExporter(subject, 
"MERMAID").getId());
+      assertNull(service.findExporter(subject, "PDF"));
+    } finally {
+      service.unregisterStaticExporter(noFormat);
+      service.unregisterStaticExporter(nullFormatId);
+    }
+  }
+
   @Test
   void testSubjectLoader() throws Exception {
     IDiagramSubjectLoader loader =
diff --git 
a/docs/hop-dev-manual/modules/ROOT/pages/plugin-types/diagram-exporters.adoc 
b/docs/hop-dev-manual/modules/ROOT/pages/plugin-types/diagram-exporters.adoc
index 2101a8e414..3c41c2726e 100644
--- a/docs/hop-dev-manual/modules/ROOT/pages/plugin-types/diagram-exporters.adoc
+++ b/docs/hop-dev-manual/modules/ROOT/pages/plugin-types/diagram-exporters.adoc
@@ -241,13 +241,17 @@ Built-in loaders: `PipelineDiagramSubjectLoader` (`.hpl`) 
and `WorkflowDiagramSu
 `DiagramExportService.findExportersForSubject(subject)` keeps every plugin 
(and any statically registered exporter) whose `supportsSubject` is true.
 The dialog lists unique format *names* from that list.
 
-`findExporter(subject, formatId)` matches, in order:
+`findExporter(subject, formatId)` returns the first of those exporters that 
matches, in upper or lower case, any of:
 
-. `exporter.getFormat().getId()` (for example `MERMAID`)
-. `exporter.getFileExtension()` (for example `mmd`)
+* `exporter.getFormat().getId()` (for example `MERMAID`)
+* `exporter.getFileExtension()` (for example `mmd`)
+* `exporter.getId()` (for example `pipeline-mermaid`)
 
+The static `findExporterForFormat(exporters, format)` does the same matching 
on any list of exporters.
 So `--format mermaid`, `--format MERMAID` and an output file ending in `.mmd` 
all select the same plugin.
-If nothing matches, the service falls back to the first exporter that supports 
the subject.
+For an exporter without a `DiagramExportFormat`, the dialog lists the 
exporter's name and passes its id as the format.
+`export(...)` uses the first exporter that supports the subject only when the 
options have no format.
+When a format is given and nothing matches, it throws a `HopException` that 
lists the formats that do support the subject; it never writes another format 
instead.
 
 `registerStaticExporter(...)` exists for tests and for code that is not a 
plugin.
 Production exporters should be `@DiagramExporter` classes so Jandex finds them.
diff --git a/docs/hop-user-manual/modules/ROOT/pages/hop-tools/hop-export.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/hop-tools/hop-export.adoc
index 1a386dc649..4ac134a2d4 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/hop-tools/hop-export.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/hop-tools/hop-export.adoc
@@ -47,7 +47,7 @@ hop export --list-exporters
 |Option|Description
 |`-f`, `--file <file>`|The pipeline (`.hpl`) or workflow (`.hwf`) to export.
 |`-o`, `--output-file <file>`|The file to write, for `-f`. By default, the 
name of the exported file with the extension of the format (`.svg` or `.mmd`), 
in the same folder.
-|`--format <format>`|`svg` or `mermaid`, in upper or lower case. Without it, 
an `-o` file that ends in `.mmd` is written as Mermaid, and one that ends in 
`.svg` as SVG. Without `--format` and `-o`, the format is SVG.
+|`--format <format>`|`svg` or `mermaid`, in upper or lower case, or another 
format that an exporter in your installation writes (see `--list-exporters`). 
Without it, the extension of the `-o` file picks the exporter that writes that 
extension: `.mmd` is written as Mermaid, and `.svg` as SVG. Without `--format` 
and `-o`, or with an `-o` file without an extension, the format is SVG. When no 
exporter in your installation writes the format, for example `pdf` or an `-o` 
file that ends in `.pd [...]
 |`-s`, `--source-folder <folder>`|The folder to export every pipeline and 
workflow from.
 |`-t`, `--target-folder <folder>`|The folder to write the diagrams to, for 
`-s`. Required with `-s`. See <<_exporting_a_folder,Exporting a folder>>.
 |`-r`, `--recursive`|With `-s`, also export the subfolders.
@@ -97,13 +97,14 @@ Each diagram is written under `-t` with the same relative 
path, for example `pip
 
 * `-t` must be an existing folder. With `-r`, its subfolders must exist as 
well.
 * The export stops at the first file it can't export, for example a diagram 
whose folder is missing under `-t`, or a file that is not valid XML. The 
diagrams written before it stay.
+* A file that no exporter for the format supports is skipped and logged, for 
example a workflow when only pipelines have an exporter for that format. The 
other files are still exported.
 * A pipeline and a workflow with the same name in the same folder are written 
to the same file, so only the last one is kept.
 
-At the end, the command logs how many diagrams it exported.
+At the end, the command logs how many diagrams it exported and how many it 
skipped.
 
 == Exit codes
 
-`hop export` ends with `0` when the export is done, and with `1` when it 
fails, for example when the source folder doesn't exist or a diagram can't be 
written.
+`hop export` ends with `0` when the export is done, and with `1` when it 
fails, for example when the source folder doesn't exist, no exporter writes the 
format, or a diagram can't be written.
 
 The `hop-export.sh` and `hop-export.bat` scripts end with other codes:
 
diff --git 
a/engine/src/main/java/org/apache/hop/diagram/command/DiagramExportCommand.java 
b/engine/src/main/java/org/apache/hop/diagram/command/DiagramExportCommand.java
index 28104bc0a2..73d808a946 100644
--- 
a/engine/src/main/java/org/apache/hop/diagram/command/DiagramExportCommand.java
+++ 
b/engine/src/main/java/org/apache/hop/diagram/command/DiagramExportCommand.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 import lombok.Getter;
 import lombok.Setter;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileType;
@@ -215,8 +216,10 @@ public class DiagramExportCommand implements Runnable, 
IHopCommand, IHasHopMetad
 
   private void doExportSingleFile() throws HopException {
     String resolvedFile = variables.resolve(filename);
-    String targetFmt = resolveTargetFormat(outputFilename, format);
-    String targetFile = resolveOutputFilename(resolvedFile, outputFilename, 
targetFmt);
+    List<IDiagramExporter<?>> exporters = 
DiagramExportService.getInstance().getAllExporters();
+    String targetFmt = resolveTargetFormat(exporters, outputFilename, format);
+    IDiagramExporter<?> exporter = requireExporterForFormat(exporters, 
targetFmt);
+    String targetFile = resolveOutputFilename(resolvedFile, outputFilename, 
exporter, targetFmt);
 
     DiagramExportOptions options = new DiagramExportOptions(targetFile, 
targetFmt);
     options.setMagnification(magnification);
@@ -233,6 +236,27 @@ public class DiagramExportCommand implements Runnable, 
IHopCommand, IHasHopMetad
     log.logBasic("Exported " + resolvedFile + " -> " + result.getFilename());
   }
 
+  /**
+   * Fails before anything is written when no installed exporter writes the 
given format, so that a
+   * typo or a format without an exporter (PDF) is not silently written as 
another format.
+   *
+   * @return the first installed exporter for the format
+   */
+  private IDiagramExporter<?> requireExporterForFormat(
+      List<IDiagramExporter<?>> exporters, String targetFmt) throws 
HopException {
+    IDiagramExporter<?> exporter = 
DiagramExportService.findExporterForFormat(exporters, targetFmt);
+    if (exporter == null) {
+      throw new HopException(
+          "No diagram exporter for format '"
+              + targetFmt
+              + "'. Available formats: "
+              + DiagramExportService.describeFormats(exporters)
+              + ". Use --list-exporters for the details.");
+    }
+    return exporter;
+  }
+
+  @SuppressWarnings({"unchecked", "rawtypes"})
   private void doBatchExport() throws HopException {
     if (StringUtils.isBlank(targetFolder)) {
       throw new HopException("Target folder (-t, --target-folder) is required 
for batch export");
@@ -250,27 +274,50 @@ public class DiagramExportCommand implements Runnable, 
IHopCommand, IHasHopMetad
       List<FileObject> filesToExport = new ArrayList<>();
       collectFiles(sourceDir, filesToExport, recursive);
 
-      String targetFmt = resolveTargetFormat(null, format);
+      DiagramExportService service = DiagramExportService.getInstance();
+      List<IDiagramExporter<?>> exporters = service.getAllExporters();
+      String targetFmt = resolveTargetFormat(exporters, null, format);
+      requireExporterForFormat(exporters, targetFmt);
       int count = 0;
+      int skipped = 0;
 
       for (FileObject file : filesToExport) {
         String relPath = sourceDir.getName().getRelativeName(file.getName());
+        IExportContext context =
+            new ExportContext(
+                variables, metadataProvider, log, 
IExportContext.ExportEnvironment.BATCH);
+        Object subject = service.loadSubject(file.getName().getURI(), context);
+
+        // A format that only some subjects have (pipelines but not workflows, 
say): skip the rest.
+        List<IDiagramExporter<?>> forSubject = new ArrayList<>();
+        for (IDiagramExporter<?> candidate : exporters) {
+          if (candidate.supportsSubject(subject)) {
+            forSubject.add(candidate);
+          }
+        }
+        IDiagramExporter exporter =
+            DiagramExportService.findExporterForFormat(forSubject, targetFmt);
+        if (exporter == null) {
+          skipped++;
+          log.logBasic(
+              "Skipped "
+                  + relPath
+                  + ": no diagram exporter for format '"
+                  + targetFmt
+                  + "' supports it");
+          continue;
+        }
+
         int lastDot = relPath.lastIndexOf('.');
         String baseName = lastDot != -1 ? relPath.substring(0, lastDot) : 
relPath;
-        String ext = targetFmt.equalsIgnoreCase("mermaid") ? "mmd" : 
targetFmt.toLowerCase();
-        String targetPath = resolvedTarget + "/" + baseName + "." + ext;
+        String targetPath =
+            resolvedTarget + "/" + baseName + "." + extensionOf(exporter, 
targetFmt);
 
         DiagramExportOptions options = new DiagramExportOptions(targetPath, 
targetFmt);
         options.setMagnification(magnification);
         options.setIncludeNotes(includeNotes);
 
-        IExportContext context =
-            new ExportContext(
-                variables, metadataProvider, log, 
IExportContext.ExportEnvironment.BATCH);
-
-        DiagramExportResult result =
-            DiagramExportService.getInstance()
-                .exportFile(file.getName().getURI(), options, context);
+        DiagramExportResult result = exporter.export(subject, options, 
context);
         if (result.isSuccess()) {
           count++;
           log.logBasic("Exported " + relPath + " -> " + targetPath);
@@ -279,7 +326,10 @@ public class DiagramExportCommand implements Runnable, 
IHopCommand, IHasHopMetad
         }
       }
 
-      log.logBasic("Batch export finished. Total diagrams exported: " + count);
+      log.logBasic(
+          "Batch export finished. Total diagrams exported: "
+              + count
+              + (skipped > 0 ? ", skipped: " + skipped : ""));
     } catch (Exception e) {
       throw new HopException("Error during batch diagram export", e);
     }
@@ -309,34 +359,53 @@ public class DiagramExportCommand implements Runnable, 
IHopCommand, IHasHopMetad
     }
   }
 
-  private String resolveTargetFormat(String outputFilePath, String 
explicitFormat) {
+  /**
+   * The format given with --format, or else the format of the installed 
exporter that writes the -o
+   * file's extension. An extension that no exporter writes, such as .png, is 
returned as it is, so
+   * that it is rejected rather than written as SVG. SVG without --format and 
without an extension.
+   */
+  private String resolveTargetFormat(
+      List<IDiagramExporter<?>> exporters, String outputFilePath, String 
explicitFormat) {
     if (StringUtils.isNotBlank(explicitFormat)) {
       return explicitFormat.trim().toUpperCase();
     }
-    if (StringUtils.isNotBlank(outputFilePath)) {
-      String lower = outputFilePath.toLowerCase();
-      if (lower.endsWith(".mmd")) {
-        return DiagramExportFormat.MERMAID.getId();
-      }
-      if (lower.endsWith(".svg")) {
-        return DiagramExportFormat.SVG.getId();
-      }
-      if (lower.endsWith(".pdf")) {
-        return DiagramExportFormat.PDF.getId();
+    String extension =
+        StringUtils.isBlank(outputFilePath)
+            ? ""
+            : FilenameUtils.getExtension(variables.resolve(outputFilePath));
+    if (StringUtils.isBlank(extension)) {
+      return DiagramExportFormat.SVG.getId();
+    }
+    for (IDiagramExporter<?> exporter : exporters) {
+      if (extension.equalsIgnoreCase(exporter.getFileExtension())) {
+        return exporter.getFormat() != null && 
StringUtils.isNotBlank(exporter.getFormat().getId())
+            ? exporter.getFormat().getId()
+            : exporter.getId();
       }
     }
-    return DiagramExportFormat.SVG.getId();
+    return extension.toUpperCase();
   }
 
   private String resolveOutputFilename(
-      String inputFilename, String explicitOutput, String targetFormat) {
+      String inputFilename,
+      String explicitOutput,
+      IDiagramExporter<?> exporter,
+      String targetFormat) {
     if (StringUtils.isNotBlank(explicitOutput)) {
       return variables.resolve(explicitOutput);
     }
     int lastDot = inputFilename.lastIndexOf('.');
     String base = lastDot != -1 ? inputFilename.substring(0, lastDot) : 
inputFilename;
-    String ext = targetFormat.equalsIgnoreCase("mermaid") ? "mmd" : 
targetFormat.toLowerCase();
-    return base + "." + ext;
+    return base + "." + extensionOf(exporter, targetFormat);
+  }
+
+  /**
+   * The exporter's file extension, for example mmd for Mermaid, or else the 
format in lowercase.
+   */
+  private static String extensionOf(IDiagramExporter<?> exporter, String 
targetFormat) {
+    return StringUtils.isNotBlank(exporter.getFileExtension())
+        ? exporter.getFileExtension()
+        : targetFormat.toLowerCase();
   }
 
   public static void main(String[] args) {
diff --git 
a/engine/src/test/java/org/apache/hop/diagram/command/DiagramExportCommandTest.java
 
b/engine/src/test/java/org/apache/hop/diagram/command/DiagramExportCommandTest.java
index df4d76b372..6dc7f88eda 100644
--- 
a/engine/src/test/java/org/apache/hop/diagram/command/DiagramExportCommandTest.java
+++ 
b/engine/src/test/java/org/apache/hop/diagram/command/DiagramExportCommandTest.java
@@ -18,10 +18,20 @@
 package org.apache.hop.diagram.command;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
+import org.apache.hop.core.diagram.BaseDiagramExporter;
+import org.apache.hop.core.diagram.DiagramExportFormat;
+import org.apache.hop.core.diagram.DiagramExportOptions;
+import org.apache.hop.core.diagram.DiagramExportResult;
+import org.apache.hop.core.diagram.DiagramExportService;
+import org.apache.hop.core.diagram.IExportContext;
+import org.apache.hop.core.exception.HopException;
 import org.apache.hop.pipeline.PipelineMeta;
 import org.apache.hop.workflow.WorkflowMeta;
 import org.junit.jupiter.api.BeforeAll;
@@ -32,6 +42,26 @@ class DiagramExportCommandTest {
 
   @TempDir Path tempDir;
 
+  /** A PlantUML exporter for pipelines only, like a plugin outside the 
built-in SVG and Mermaid. */
+  static class PipelinePlantUmlExporter extends 
BaseDiagramExporter<PipelineMeta> {
+    PipelinePlantUmlExporter() {
+      id = "test-pipeline-plantuml";
+      name = "Test PlantUML";
+      format = DiagramExportFormat.PLANTUML;
+      fileExtension = "puml";
+      supportedSubjectTypes = new Class<?>[] {PipelineMeta.class};
+    }
+
+    @Override
+    public DiagramExportResult export(
+        PipelineMeta subject, DiagramExportOptions options, IExportContext 
context)
+        throws HopException {
+      String content = "@startuml\n@enduml\n";
+      writeToTarget(options.getTargetFilename(), content, context);
+      return DiagramExportResult.success(options.getTargetFilename(), content, 
"text/plain");
+    }
+  }
+
   @BeforeAll
   static void initHop() throws Exception {
     org.apache.hop.core.HopEnvironment.init();
@@ -67,6 +97,102 @@ class DiagramExportCommandTest {
     assertTrue(content.contains("flowchart LR"));
   }
 
+  @Test
+  void testExportWithoutExporterForFormatFails() throws Exception {
+    PipelineMeta pipelineMeta = new PipelineMeta();
+    pipelineMeta.setName("cli-test-pipeline");
+    Path pipelineFile = tempDir.resolve("test-pipeline.hpl");
+    Files.writeString(
+        pipelineFile, pipelineMeta.getXml(new 
org.apache.hop.core.variables.Variables()));
+
+    // --format pdf, without -o: would be written next to the pipeline as 
test-pipeline.pdf
+    DiagramExportCommand pdfFormat = new DiagramExportCommand();
+    pdfFormat.setFilename(pipelineFile.toString());
+    pdfFormat.setFormat("pdf");
+    RuntimeException e = assertThrows(RuntimeException.class, pdfFormat::run);
+    assertTrue(e.getCause().getMessage().contains("'PDF'"), 
e.getCause().getMessage());
+    assertTrue(e.getCause().getMessage().contains("MERMAID (.mmd)"), 
e.getCause().getMessage());
+    assertTrue(e.getCause().getMessage().contains("SVG (.svg)"), 
e.getCause().getMessage());
+    assertFalse(Files.exists(tempDir.resolve("test-pipeline.pdf")));
+
+    // -o x.pdf, without --format
+    Path pdfFile = tempDir.resolve("x.pdf");
+    DiagramExportCommand pdfOutput = new DiagramExportCommand();
+    pdfOutput.setFilename(pipelineFile.toString());
+    pdfOutput.setOutputFilename(pdfFile.toString());
+    assertThrows(RuntimeException.class, pdfOutput::run);
+    assertFalse(Files.exists(pdfFile));
+
+    // a typo
+    Path fooFile = tempDir.resolve("y.foo");
+    DiagramExportCommand typo = new DiagramExportCommand();
+    typo.setFilename(pipelineFile.toString());
+    typo.setOutputFilename(fooFile.toString());
+    typo.setFormat("foo");
+    assertThrows(RuntimeException.class, typo::run);
+    assertFalse(Files.exists(fooFile));
+  }
+
+  /** -o x.png, without --format, was written as SVG into x.png. */
+  @Test
+  void testExportToAnExtensionWithoutExporterFails() throws Exception {
+    Path pipelineFile = writePipeline("test-pipeline.hpl");
+    Path pngFile = tempDir.resolve("x.png");
+
+    DiagramExportCommand cmd = new DiagramExportCommand();
+    cmd.setFilename(pipelineFile.toString());
+    cmd.setOutputFilename(pngFile.toString());
+    RuntimeException e = assertThrows(RuntimeException.class, cmd::run);
+
+    assertTrue(e.getCause().getMessage().contains("'PNG'"), 
e.getCause().getMessage());
+    assertTrue(e.getCause().getMessage().contains("SVG (.svg)"), 
e.getCause().getMessage());
+    assertFalse(Files.exists(pngFile));
+  }
+
+  @Test
+  void testExportToAFileWithoutExtensionIsSvg() throws Exception {
+    Path pipelineFile = writePipeline("test-pipeline.hpl");
+    Path outputFile = tempDir.resolve("diagram");
+
+    DiagramExportCommand cmd = new DiagramExportCommand();
+    cmd.setFilename(pipelineFile.toString());
+    cmd.setOutputFilename(outputFile.toString());
+    assertDoesNotThrow(cmd::run);
+
+    assertTrue(Files.readString(outputFile).contains("<svg"));
+  }
+
+  private Path writePipeline(String name) throws Exception {
+    PipelineMeta pipelineMeta = new PipelineMeta();
+    pipelineMeta.setName("cli-test-pipeline");
+    Path pipelineFile = tempDir.resolve(name);
+    Files.writeString(
+        pipelineFile, pipelineMeta.getXml(new 
org.apache.hop.core.variables.Variables()));
+    return pipelineFile;
+  }
+
+  @Test
+  void testBatchExportWithoutExporterForFormatFails() throws Exception {
+    Path sourceFolder = tempDir.resolve("source");
+    Path targetFolder = tempDir.resolve("target");
+    Files.createDirectories(sourceFolder);
+    Files.createDirectories(targetFolder);
+
+    PipelineMeta pipelineMeta = new PipelineMeta();
+    pipelineMeta.setName("batch-pipe");
+    Files.writeString(
+        sourceFolder.resolve("pipe.hpl"),
+        pipelineMeta.getXml(new org.apache.hop.core.variables.Variables()));
+
+    DiagramExportCommand cmd = new DiagramExportCommand();
+    cmd.setSourceFolder(sourceFolder.toString());
+    cmd.setTargetFolder(targetFolder.toString());
+    cmd.setFormat("pdf");
+
+    assertThrows(RuntimeException.class, cmd::run);
+    assertFalse(Files.exists(targetFolder.resolve("pipe.pdf")));
+  }
+
   @Test
   void testBatchExport() throws Exception {
     Path sourceFolder = tempDir.resolve("source");
@@ -96,4 +222,73 @@ class DiagramExportCommandTest {
     assertTrue(Files.exists(targetFolder.resolve("pipe.svg")));
     assertTrue(Files.exists(targetFolder.resolve("flow.svg")));
   }
+
+  /** -o x.puml, without --format, picks an installed exporter that writes 
.puml. */
+  @Test
+  void testExportToAnInstalledExtensionUsesItsExporter() throws Exception {
+    PipelinePlantUmlExporter plantUml = new PipelinePlantUmlExporter();
+    DiagramExportService.getInstance().registerStaticExporter(plantUml);
+    try {
+      Path pipelineFile = writePipeline("test-pipeline.hpl");
+      Path pumlFile = tempDir.resolve("x.puml");
+
+      DiagramExportCommand cmd = new DiagramExportCommand();
+      cmd.setFilename(pipelineFile.toString());
+      cmd.setOutputFilename(pumlFile.toString());
+      assertDoesNotThrow(cmd::run);
+      assertTrue(Files.readString(pumlFile).startsWith("@startuml"));
+
+      // Without -o, the file gets the exporter's extension, not .plantuml
+      DiagramExportCommand byFormat = new DiagramExportCommand();
+      byFormat.setFilename(pipelineFile.toString());
+      byFormat.setFormat("plantuml");
+      assertDoesNotThrow(byFormat::run);
+      assertTrue(Files.exists(tempDir.resolve("test-pipeline.puml")));
+    } finally {
+      DiagramExportService.getInstance().unregisterStaticExporter(plantUml);
+    }
+  }
+
+  /**
+   * A format that only pipelines have skips the workflows, and exports every 
pipeline, rather than
+   * stopping at the first workflow.
+   */
+  @Test
+  void testBatchExportSkipsFilesWithoutExporterForFormat() throws Exception {
+    PipelinePlantUmlExporter plantUml = new PipelinePlantUmlExporter();
+    DiagramExportService.getInstance().registerStaticExporter(plantUml);
+    try {
+      Path sourceFolder = tempDir.resolve("source");
+      Path targetFolder = tempDir.resolve("target");
+      Files.createDirectories(sourceFolder);
+      Files.createDirectories(targetFolder);
+
+      for (String name : new String[] {"a-pipe", "z-pipe"}) {
+        PipelineMeta pipelineMeta = new PipelineMeta();
+        pipelineMeta.setName(name);
+        Files.writeString(
+            sourceFolder.resolve(name + ".hpl"),
+            pipelineMeta.getXml(new 
org.apache.hop.core.variables.Variables()));
+      }
+      WorkflowMeta workflowMeta = new WorkflowMeta();
+      workflowMeta.setName("m-flow");
+      Files.writeString(
+          sourceFolder.resolve("m-flow.hwf"),
+          workflowMeta.getXml(new org.apache.hop.core.variables.Variables()));
+
+      DiagramExportCommand cmd = new DiagramExportCommand();
+      cmd.setSourceFolder(sourceFolder.toString());
+      cmd.setTargetFolder(targetFolder.toString());
+      cmd.setFormat("plantuml");
+      assertDoesNotThrow(cmd::run);
+
+      assertTrue(Files.exists(targetFolder.resolve("a-pipe.puml")));
+      assertTrue(Files.exists(targetFolder.resolve("z-pipe.puml")));
+      try (var files = Files.list(targetFolder)) {
+        assertEquals(2, files.count());
+      }
+    } finally {
+      DiagramExportService.getInstance().unregisterStaticExporter(plantUml);
+    }
+  }
 }
diff --git a/integration-tests/export/dev-env-config.json 
b/integration-tests/export/dev-env-config.json
new file mode 100644
index 0000000000..a1ca51bc29
--- /dev/null
+++ b/integration-tests/export/dev-env-config.json
@@ -0,0 +1,9 @@
+{
+  "variables": [
+    {
+      "name": "SAMPLE",
+      "value": "sampleValue",
+      "description": "A sample variable value"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/integration-tests/export/hop-config.json 
b/integration-tests/export/hop-config.json
new file mode 100644
index 0000000000..d9e1e6562e
--- /dev/null
+++ b/integration-tests/export/hop-config.json
@@ -0,0 +1,290 @@
+{
+  "variables": [
+    {
+      "name": "HOP_LENIENT_STRING_TO_NUMBER_CONVERSION",
+      "value": "N",
+      "description": "System wide flag to allow lenient string to number 
conversion for backward compatibility. If this setting is set to \"Y\", an 
string starting with digits will be converted successfully into a number. 
(example: 192.168.1.1 will be converted into 192 or 192.168 or 192168 depending 
on the decimal and grouping symbol). The default (N) will be to throw an error 
if non-numeric symbols are found in the string."
+    },
+    {
+      "name": "HOP_COMPATIBILITY_DB_IGNORE_TIMEZONE",
+      "value": "N",
+      "description": "System wide flag to ignore timezone while writing 
date/timestamp value to the database."
+    },
+    {
+      "name": "HOP_LOG_SIZE_LIMIT",
+      "value": "0",
+      "description": "The log size limit for all pipelines and workflows that 
don't have the \"log size limit\" property set in their respective properties."
+    },
+    {
+      "name": "HOP_EMPTY_STRING_DIFFERS_FROM_NULL",
+      "value": "N",
+      "description": "NULL vs Empty String. If this setting is set to Y, an 
empty string and null are different. Otherwise they are not."
+    },
+    {
+      "name": "HOP_MAX_LOG_SIZE_IN_LINES",
+      "value": "0",
+      "description": "The maximum number of log lines that are kept internally 
by Hop. Set to 0 to keep all rows (default)"
+    },
+    {
+      "name": "HOP_MAX_LOG_TIMEOUT_IN_MINUTES",
+      "value": "1440",
+      "description": "The maximum age (in minutes) of a log line while being 
kept internally by Hop. Set to 0 to keep all rows indefinitely (default)"
+    },
+    {
+      "name": "HOP_MAX_WORKFLOW_TRACKER_SIZE",
+      "value": "5000",
+      "description": "The maximum number of workflow trackers kept in memory"
+    },
+    {
+      "name": "HOP_MAX_ACTIONS_LOGGED",
+      "value": "5000",
+      "description": "The maximum number of action results kept in memory for 
logging purposes."
+    },
+    {
+      "name": "HOP_MAX_LOGGING_REGISTRY_SIZE",
+      "value": "10000",
+      "description": "The maximum number of logging registry entries kept in 
memory for logging purposes."
+    },
+    {
+      "name": "HOP_LOG_TAB_REFRESH_DELAY",
+      "value": "1000",
+      "description": "The hop log tab refresh delay."
+    },
+    {
+      "name": "HOP_LOG_TAB_REFRESH_PERIOD",
+      "value": "1000",
+      "description": "The hop log tab refresh period."
+    },
+    {
+      "name": "HOP_PLUGIN_CLASSES",
+      "value": null,
+      "description": "A comma delimited list of classes to scan for plugin 
annotations"
+    },
+    {
+      "name": "HOP_PLUGIN_PACKAGES",
+      "value": null,
+      "description": "A comma delimited list of packages to scan for plugin 
annotations (warning: slow!!)"
+    },
+    {
+      "name": "HOP_TRANSFORM_PERFORMANCE_SNAPSHOT_LIMIT",
+      "value": "0",
+      "description": "The maximum number of transform performance snapshots to 
keep in memory. Set to 0 to keep all snapshots indefinitely (default)"
+    },
+    {
+      "name": "HOP_ROWSET_GET_TIMEOUT",
+      "value": "50",
+      "description": "The name of the variable that optionally contains an 
alternative rowset get timeout (in ms). This only makes a difference for 
extremely short lived pipelines."
+    },
+    {
+      "name": "HOP_ROWSET_PUT_TIMEOUT",
+      "value": "50",
+      "description": "The name of the variable that optionally contains an 
alternative rowset put timeout (in ms). This only makes a difference for 
extremely short lived pipelines."
+    },
+    {
+      "name": "HOP_CORE_TRANSFORMS_FILE",
+      "value": null,
+      "description": "The name of the project variable that will contain the 
alternative location of the hop-transforms.xml file. You can use this to 
customize the list of available internal transforms outside of the codebase."
+    },
+    {
+      "name": "HOP_CORE_WORKFLOW_ACTIONS_FILE",
+      "value": null,
+      "description": "The name of the project variable that will contain the 
alternative location of the hop-workflow-actions.xml file."
+    },
+    {
+      "name": "HOP_SERVER_OBJECT_TIMEOUT_MINUTES",
+      "value": "1440",
+      "description": "This project variable will set a time-out after which 
waiting, completed or stopped pipelines and workflows will be automatically 
cleaned up. The default value is 1440 (one day)."
+    },
+    {
+      "name": "HOP_PIPELINE_PAN_JVM_EXIT_CODE",
+      "value": null,
+      "description": "Set this variable to an integer that will be returned as 
the Pan JVM exit code."
+    },
+    {
+      "name": "HOP_DISABLE_CONSOLE_LOGGING",
+      "value": "N",
+      "description": "Set this variable to Y to disable standard Hop logging 
to the console. (stdout)"
+    },
+    {
+      "name": "HOP_REDIRECT_STDERR",
+      "value": "N",
+      "description": "Set this variable to Y to redirect stderr to Hop 
logging."
+    },
+    {
+      "name": "HOP_REDIRECT_STDOUT",
+      "value": "N",
+      "description": "Set this variable to Y to redirect stdout to Hop 
logging."
+    },
+    {
+      "name": "HOP_DEFAULT_NUMBER_FORMAT",
+      "value": null,
+      "description": "The name of the variable containing an alternative 
default number format"
+    },
+    {
+      "name": "HOP_DEFAULT_BIGNUMBER_FORMAT",
+      "value": null,
+      "description": "The name of the variable containing an alternative 
default bignumber format"
+    },
+    {
+      "name": "HOP_DEFAULT_INTEGER_FORMAT",
+      "value": null,
+      "description": "The name of the variable containing an alternative 
default integer format"
+    },
+    {
+      "name": "HOP_DEFAULT_DATE_FORMAT",
+      "value": null,
+      "description": "The name of the variable containing an alternative 
default date format"
+    },
+    {
+      "name": "HOP_DEFAULT_TIMESTAMP_FORMAT",
+      "value": null,
+      "description": "The name of the variable containing an alternative 
default timestamp format"
+    },
+    {
+      "name": "HOP_DEFAULT_SERVLET_ENCODING",
+      "value": null,
+      "description": "Defines the default encoding for servlets, leave it 
empty to use Java default encoding"
+    },
+    {
+      "name": "HOP_FAIL_ON_LOGGING_ERROR",
+      "value": "N",
+      "description": "Set this variable to Y when you want the 
workflow/pipeline fail with an error when the related logging process (e.g. to 
a database) fails."
+    },
+    {
+      "name": "HOP_AGGREGATION_MIN_NULL_IS_VALUED",
+      "value": "N",
+      "description": "Set this variable to Y to set the minimum to NULL if 
NULL is within an aggregate. Otherwise by default NULL is ignored by the MIN 
aggregate and MIN is set to the minimum value that is not NULL. See also the 
variable HOP_AGGREGATION_ALL_NULLS_ARE_ZERO."
+    },
+    {
+      "name": "HOP_AGGREGATION_ALL_NULLS_ARE_ZERO",
+      "value": "N",
+      "description": "Set this variable to Y to return 0 when all values 
within an aggregate are NULL. Otherwise by default a NULL is returned when all 
values are NULL."
+    },
+    {
+      "name": "HOP_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER",
+      "value": "N",
+      "description": "Set this variable to Y for backward compatibility for 
the Text File Output transform. Setting this to Ywill add no header row at all 
when the append option is enabled, regardless if the file is existing or not."
+    },
+    {
+      "name": "HOP_PASSWORD_ENCODER_PLUGIN",
+      "value": "Hop",
+      "description": "Specifies the password encoder plugin to use by ID (Hop 
is the default)."
+    },
+    {
+      "name": "HOP_SYSTEM_HOSTNAME",
+      "value": null,
+      "description": "You can use this variable to speed up hostname lookup. 
Hostname lookup is performed by Hop so that it is capable of logging the server 
on which a workflow or pipeline is executed."
+    },
+    {
+      "name": "HOP_SERVER_JETTY_ACCEPTORS",
+      "value": null,
+      "description": "A variable to configure jetty option: acceptors for 
Carte"
+    },
+    {
+      "name": "HOP_SERVER_JETTY_ACCEPT_QUEUE_SIZE",
+      "value": null,
+      "description": "A variable to configure jetty option: acceptQueueSize 
for Carte"
+    },
+    {
+      "name": "HOP_SERVER_JETTY_RES_MAX_IDLE_TIME",
+      "value": null,
+      "description": "A variable to configure jetty option: 
lowResourcesMaxIdleTime for Carte"
+    },
+    {
+      "name": 
"HOP_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL",
+      "value": "N",
+      "description": "Set this variable to Y for backward compatibility for 
the Merge Rows (diff) transform. Setting this to Y will use the data from the 
reference stream (instead of the comparison stream) in case the compared rows 
are identical."
+    },
+    {
+      "name": "HOP_SPLIT_FIELDS_REMOVE_ENCLOSURE",
+      "value": "false",
+      "description": "Set this variable to false to preserve enclosure symbol 
after splitting the string in the Split fields transform. Changing it to true 
will remove first and last enclosure symbol from the resulting string chunks."
+    },
+    {
+      "name": "HOP_ALLOW_EMPTY_FIELD_NAMES_AND_TYPES",
+      "value": "false",
+      "description": "Set this variable to TRUE to allow your pipeline to pass 
'null' fields and/or empty types."
+    },
+    {
+      "name": "HOP_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT",
+      "value": "false",
+      "description": "Set this variable to false to preserve global log 
variables defined in pipeline / workflow Properties -> Log panel. Changing it 
to true will clear it when export pipeline / workflow."
+    },
+    {
+      "name": "HOP_FILE_OUTPUT_MAX_STREAM_COUNT",
+      "value": "1024",
+      "description": "This project variable is used by the Text File Output 
transform. It defines the max number of simultaneously open files within the 
transform. The transform will close/reopen files as necessary to insure the max 
is not exceeded"
+    },
+    {
+      "name": "HOP_FILE_OUTPUT_MAX_STREAM_LIFE",
+      "value": "0",
+      "description": "This project variable is used by the Text File Output 
transform. It defines the max number of milliseconds between flushes of files 
opened by the transform."
+    },
+    {
+      "name": "HOP_USE_NATIVE_FILE_DIALOG",
+      "value": "N",
+      "description": "Set this value to Y if you want to use the system file 
open/save dialog when browsing files"
+    },
+    {
+      "name": "HOP_AUTO_CREATE_CONFIG",
+      "value": "Y",
+      "description": "Set this value to N if you don't want to automatically 
create a hop configuration file (hop-config.json) when it's missing"
+    }
+  ],
+  "LocaleDefault": "en_BE",
+  "guiProperties": {
+    "FontFixedSize": "13",
+    "MaxUndo": "100",
+    "DarkMode": "Y",
+    "FontNoteSize": "13",
+    "ShowOSLook": "Y",
+    "FontFixedStyle": "0",
+    "FontNoteName": ".AppleSystemUIFont",
+    "FontFixedName": "Monospaced",
+    "FontGraphStyle": "0",
+    "FontDefaultSize": "13",
+    "GraphColorR": "255",
+    "FontGraphSize": "13",
+    "IconSize": "32",
+    "BackgroundColorB": "255",
+    "FontNoteStyle": "0",
+    "FontGraphName": ".AppleSystemUIFont",
+    "FontDefaultName": ".AppleSystemUIFont",
+    "GraphColorG": "255",
+    "UseGlobalFileBookmarks": "Y",
+    "FontDefaultStyle": "0",
+    "GraphColorB": "255",
+    "BackgroundColorR": "255",
+    "BackgroundColorG": "255",
+    "WorkflowDialogStyle": "RESIZE,MAX,MIN",
+    "LineWidth": "1",
+    "ContextDialogShowCategories": "Y"
+  },
+  "projectsConfig": {
+    "enabled": true,
+    "projectMandatory": true,
+    "environmentMandatory": false,
+    "defaultProject": "default",
+    "defaultEnvironment": null,
+    "standardParentProject": "default",
+    "standardProjectsFolder": null,
+    "projectConfigurations": [
+      {
+        "projectName": "default",
+        "projectHome": "${HOP_CONFIG_FOLDER}",
+        "configFilename": "project-config.json"
+      }
+    ],
+    "lifecycleEnvironments": [
+      {
+        "name": "dev",
+        "purpose": "Testing",
+        "projectName": "default",
+        "configurationFiles": [
+          "${PROJECT_HOME}/dev-env-config.json"
+        ]
+      }
+    ],
+    "projectLifecycles": []
+  }
+}
\ No newline at end of file
diff --git a/integration-tests/export/main-0001-export-known-formats.hwf 
b/integration-tests/export/main-0001-export-known-formats.hwf
new file mode 100644
index 0000000000..4ebe39698f
--- /dev/null
+++ b/integration-tests/export/main-0001-export-known-formats.hwf
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0001-export-known-formats</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description>hop export and hop-export.sh still write SVG and Mermaid, 
picked by --format, by the -o extension or by default</description>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2026/11/08 10:00:00.000</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2026/11/08 10:00:00.000</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <DayOfMonth>1</DayOfMonth>
+      <hour>12</hour>
+      <intervalMinutes>60</intervalMinutes>
+      <intervalSeconds>0</intervalSeconds>
+      <minutes>0</minutes>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <weekDay>1</weekDay>
+      <parallel>N</parallel>
+      <xloc>112</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Export as SVG and Mermaid</name>
+      <description/>
+      <type>SHELL</type>
+      <attributes/>
+      <filename/>
+      <work_directory/>
+      <arg_from_previous>N</arg_from_previous>
+      <exec_per_row>N</exec_per_row>
+      <set_logfile>N</set_logfile>
+      <logfile/>
+      <set_append_logfile>N</set_append_logfile>
+      <logext/>
+      <add_date>N</add_date>
+      <add_time>N</add_time>
+      <insertScript>Y</insertScript>
+      <script>set -e
+SUBJECT="${PROJECT_HOME}/subject"
+OUT="${PROJECT_HOME}/output/0001-known-formats"
+rm -rf "$OUT"
+
+fail() {
+  echo "$1"
+  exit 1
+}
+
+# The same checks for both launchers: "hop export" and hop-export.sh.
+for LAUNCHER in "bash hop export" "bash hop-export.sh"; do
+  DIR="$OUT/$(echo "$LAUNCHER" | tr ' .' '__')"
+  mkdir -p "$DIR/batch"
+
+  $LAUNCHER -f "$SUBJECT/fast-pipeline.hpl" --format svg -o "$DIR/p.svg"
+  grep -q '&lt;svg' "$DIR/p.svg" || fail "$LAUNCHER --format svg did not write 
an SVG"
+
+  $LAUNCHER -f "$SUBJECT/fast-pipeline.hpl" --format MERMAID -o "$DIR/p.mmd"
+  head -1 "$DIR/p.mmd" | grep -q '^flowchart' || fail "$LAUNCHER --format 
MERMAID did not write Mermaid"
+
+  # Without --format, the extension of -o picks the format.
+  $LAUNCHER -f "$SUBJECT/fast-pipeline.hpl" -o "$DIR/by-extension.mmd"
+  head -1 "$DIR/by-extension.mmd" | grep -q '^flowchart' || fail "$LAUNCHER -o 
.mmd did not write Mermaid"
+  $LAUNCHER -f "$SUBJECT/fast-pipeline.hpl" -o "$DIR/by-extension.svg"
+  grep -q '&lt;svg' "$DIR/by-extension.svg" || fail "$LAUNCHER -o .svg did not 
write an SVG"
+
+  # Without --format and -o, an SVG next to the file.
+  cp "$SUBJECT/fast-workflow.hwf" "$DIR/default.hwf"
+  $LAUNCHER -f "$DIR/default.hwf"
+  grep -q '&lt;svg' "$DIR/default.svg" || fail "$LAUNCHER without a format did 
not write default.svg"
+
+  $LAUNCHER -f "$SUBJECT/fast-workflow.hwf" --format mermaid -o "$DIR/w.mmd"
+  head -1 "$DIR/w.mmd" | grep -q '^flowchart' || fail "$LAUNCHER did not write 
a workflow as Mermaid"
+
+  $LAUNCHER -s "$SUBJECT" -t "$DIR/batch" --format mermaid
+  test -f "$DIR/batch/fast-pipeline.mmd" || fail "$LAUNCHER -s did not export 
the pipeline"
+  test -f "$DIR/batch/fast-workflow.mmd" || fail "$LAUNCHER -s did not export 
the workflow"
+done</script>
+      <loglevel>Basic</loglevel>
+      <parallel>N</parallel>
+      <xloc>288</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Success</name>
+      <description/>
+      <type>SUCCESS</type>
+      <attributes/>
+      <parallel>N</parallel>
+      <xloc>464</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Failure: hop export did not write SVG or Mermaid</name>
+      <description/>
+      <type>ABORT</type>
+      <attributes/>
+      <always_log_rows>N</always_log_rows>
+      <message>Failure: hop export did not write SVG or Mermaid</message>
+      <parallel>N</parallel>
+      <xloc>464</xloc>
+      <yloc>192</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>Export as SVG and Mermaid</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+    <hop>
+      <from>Export as SVG and Mermaid</from>
+      <to>Success</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+    <hop>
+      <from>Export as SVG and Mermaid</from>
+      <to>Failure: hop export did not write SVG or Mermaid</to>
+      <enabled>Y</enabled>
+      <evaluation>N</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+    <notepad>
+      <backgroundcolorblue>210</backgroundcolorblue>
+      <backgroundcolorgreen>136</backgroundcolorgreen>
+      <backgroundcolorred>15</backgroundcolorred>
+      <bordercolorblue>250</bordercolorblue>
+      <bordercolorgreen>231</bordercolorgreen>
+      <bordercolorred>200</bordercolorred>
+      <fontbold>N</fontbold>
+      <fontcolorblue>250</fontcolorblue>
+      <fontcolorgreen>231</fontcolorgreen>
+      <fontcolorred>200</fontcolorred>
+      <fontitalic>N</fontitalic>
+      <fontname>Noto Sans</fontname>
+      <fontsize>10</fontsize>
+      <height>100</height>
+      <xloc>80</xloc>
+      <yloc>256</yloc>
+      <note>Exports a pipeline and a workflow with both launchers: --format 
svg / MERMAID / mermaid,
+-o files ending in .mmd and .svg without --format, no format and no -o (an SVG 
next to the file),
+and a folder export with -s and -t. Guards the formats that do have an 
exporter (issue #9383).</note>
+      <width>560</width>
+    </notepad>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git a/integration-tests/export/main-0002-export-unknown-format-fails.hwf 
b/integration-tests/export/main-0002-export-unknown-format-fails.hwf
new file mode 100644
index 0000000000..2453e6bc5b
--- /dev/null
+++ b/integration-tests/export/main-0002-export-unknown-format-fails.hwf
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0002-export-unknown-format-fails</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description>hop export fails, and writes nothing, for a format without an 
exporter</description>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2026/11/08 10:00:00.000</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2026/11/08 10:00:00.000</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <DayOfMonth>1</DayOfMonth>
+      <hour>12</hour>
+      <intervalMinutes>60</intervalMinutes>
+      <intervalSeconds>0</intervalSeconds>
+      <minutes>0</minutes>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <weekDay>1</weekDay>
+      <parallel>N</parallel>
+      <xloc>112</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Export as PDF and as a typo</name>
+      <description/>
+      <type>SHELL</type>
+      <attributes/>
+      <filename/>
+      <work_directory/>
+      <arg_from_previous>N</arg_from_previous>
+      <exec_per_row>N</exec_per_row>
+      <set_logfile>N</set_logfile>
+      <logfile/>
+      <set_append_logfile>N</set_append_logfile>
+      <logext/>
+      <add_date>N</add_date>
+      <add_time>N</add_time>
+      <insertScript>Y</insertScript>
+      <script>SUBJECT="${PROJECT_HOME}/subject"
+OUT="${PROJECT_HOME}/output/0002-unknown-format"
+rm -rf "$OUT"
+
+fail() {
+  echo "$1"
+  test -f "$OUT/last.log" &amp;&amp; cat "$OUT/last.log"
+  exit 1
+}
+
+# expect_failure EXIT_CODE FORMAT_ID LAUNCHER_ARGS...
+# The command must end with EXIT_CODE, name FORMAT_ID and list the formats 
that do exist.
+expect_failure() {
+  CODE="$1"
+  FORMAT="$2"
+  shift 2
+  "$@" &gt; "$OUT/last.log" 2&gt;&amp;1
+  RC=$?
+  test "$RC" = "$CODE" || fail "expected exit code $CODE, got $RC: $*"
+  grep -q "No diagram exporter for format '$FORMAT'" "$OUT/last.log" \
+    || fail "the error does not name format $FORMAT: $*"
+  grep -q 'MERMAID (.mmd)' "$OUT/last.log" &amp;&amp; grep -q 'SVG (.svg)' 
"$OUT/last.log" \
+    || fail "the error does not list the available formats: $*"
+}
+
+# "hop export" ends with 1 on a failure, hop-export.sh with 2 (see the 
hop-export docs).
+for SPEC in "1 hop" "2 hop-export.sh"; do
+  set -- $SPEC
+  CODE="$1"
+  if [ "$2" = "hop" ]; then LAUNCHER="bash hop export"; else LAUNCHER="bash 
hop-export.sh"; fi
+  DIR="$OUT/$2"
+  mkdir -p "$DIR/batch"
+  cp "$SUBJECT/fast-pipeline.hpl" "$DIR/fast-pipeline.hpl"
+  cp "$SUBJECT/fast-workflow.hwf" "$DIR/fast-workflow.hwf"
+
+  # --format pdf: there is no PDF exporter, and the default target is 
fast-pipeline.pdf
+  expect_failure "$CODE" PDF $LAUNCHER -f "$DIR/fast-pipeline.hpl" --format pdf
+  test ! -e "$DIR/fast-pipeline.pdf" || fail "$LAUNCHER --format pdf wrote 
fast-pipeline.pdf"
+
+  expect_failure "$CODE" PDF $LAUNCHER -f "$DIR/fast-workflow.hwf" --format pdf
+  test ! -e "$DIR/fast-workflow.pdf" || fail "$LAUNCHER --format pdf wrote 
fast-workflow.pdf"
+
+  # -o x.pdf without --format
+  expect_failure "$CODE" PDF $LAUNCHER -f "$DIR/fast-pipeline.hpl" -o 
"$DIR/x.pdf"
+  test ! -e "$DIR/x.pdf" || fail "$LAUNCHER -o x.pdf wrote x.pdf"
+
+  # -o x.png without --format: an extension no exporter writes
+  expect_failure "$CODE" PNG $LAUNCHER -f "$DIR/fast-pipeline.hpl" -o 
"$DIR/x.png"
+  test ! -e "$DIR/x.png" || fail "$LAUNCHER -o x.png wrote x.png"
+
+  # a typo
+  expect_failure "$CODE" FOO $LAUNCHER -f "$DIR/fast-pipeline.hpl" --format 
foo -o "$DIR/y.foo"
+  test ! -e "$DIR/y.foo" || fail "$LAUNCHER --format foo wrote y.foo"
+
+  # a folder export
+  expect_failure "$CODE" PDF $LAUNCHER -s "$SUBJECT" -t "$DIR/batch" --format 
pdf
+  test -z "$(ls -A "$DIR/batch")" || fail "$LAUNCHER -s --format pdf wrote 
$(ls "$DIR/batch")"
+done</script>
+      <loglevel>Basic</loglevel>
+      <parallel>N</parallel>
+      <xloc>288</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Success</name>
+      <description/>
+      <type>SUCCESS</type>
+      <attributes/>
+      <parallel>N</parallel>
+      <xloc>464</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Failure: hop export wrote a format it has no exporter for</name>
+      <description/>
+      <type>ABORT</type>
+      <attributes/>
+      <always_log_rows>N</always_log_rows>
+      <message>Failure: hop export wrote a format it has no exporter 
for</message>
+      <parallel>N</parallel>
+      <xloc>464</xloc>
+      <yloc>192</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>Export as PDF and as a typo</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+    <hop>
+      <from>Export as PDF and as a typo</from>
+      <to>Success</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+    <hop>
+      <from>Export as PDF and as a typo</from>
+      <to>Failure: hop export wrote a format it has no exporter for</to>
+      <enabled>Y</enabled>
+      <evaluation>N</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+    <notepad>
+      <backgroundcolorblue>210</backgroundcolorblue>
+      <backgroundcolorgreen>136</backgroundcolorgreen>
+      <backgroundcolorred>15</backgroundcolorred>
+      <bordercolorblue>250</bordercolorblue>
+      <bordercolorgreen>231</bordercolorgreen>
+      <bordercolorred>200</bordercolorred>
+      <fontbold>N</fontbold>
+      <fontcolorblue>250</fontcolorblue>
+      <fontcolorgreen>231</fontcolorgreen>
+      <fontcolorred>200</fontcolorred>
+      <fontitalic>N</fontitalic>
+      <fontname>Noto Sans</fontname>
+      <fontsize>10</fontsize>
+      <height>100</height>
+      <xloc>80</xloc>
+      <yloc>256</yloc>
+      <note>A standard installation has no PDF exporter. hop export used to 
write a Mermaid diagram under
+the .pdf (or .foo) name and end with exit code 0 (issue #9383).
+
+Each case must end with a non-zero exit code (1 for hop export, 2 for 
hop-export.sh), name the
+format, list MERMAID (.mmd) and SVG (.svg), and leave no file behind.</note>
+      <width>560</width>
+    </notepad>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git 
a/integration-tests/export/metadata/pipeline-run-configuration/local.json 
b/integration-tests/export/metadata/pipeline-run-configuration/local.json
new file mode 100644
index 0000000000..63794efcaf
--- /dev/null
+++ b/integration-tests/export/metadata/pipeline-run-configuration/local.json
@@ -0,0 +1,17 @@
+{
+  "engineRunConfiguration": {
+    "Local": {
+      "feedback_size": "50000",
+      "sample_size": "100",
+      "sample_type_in_gui": "Last",
+      "rowset_size": "10000",
+      "safe_mode": false,
+      "show_feedback": false,
+      "topo_sort": false,
+      "gather_metrics": false
+    }
+  },
+  "configurationVariables": [],
+  "name": "local",
+  "description": "Runs your pipelines locally with the standard local Hop 
pipeline engine"
+}
\ No newline at end of file
diff --git 
a/integration-tests/export/metadata/workflow-run-configuration/local.json 
b/integration-tests/export/metadata/workflow-run-configuration/local.json
new file mode 100644
index 0000000000..e37a93039a
--- /dev/null
+++ b/integration-tests/export/metadata/workflow-run-configuration/local.json
@@ -0,0 +1,9 @@
+{
+  "engineRunConfiguration": {
+    "Local": {
+      "safe_mode": false
+    }
+  },
+  "name": "local",
+  "description": "Runs your workflows locally with the standard local Hop 
workflow engine"
+}
\ No newline at end of file
diff --git a/integration-tests/export/project-config.json 
b/integration-tests/export/project-config.json
new file mode 100644
index 0000000000..6a91171e1c
--- /dev/null
+++ b/integration-tests/export/project-config.json
@@ -0,0 +1,13 @@
+{
+  "metadataBaseFolder" : "${PROJECT_HOME}/metadata",
+  "unitTestsBasePath" : "${PROJECT_HOME}",
+  "dataSetsCsvFolder" : "${PROJECT_HOME}/datasets",
+  "enforcingExecutionInHome" : true,
+  "config" : {
+    "variables" : [ {
+      "name" : "HOP_LICENSE_HEADER_FILE",
+      "value" : "${PROJECT_HOME}/../asf-header.txt",
+      "description" : "This will automatically serialize the ASF license 
header into pipelines and workflows in the integration test projects"
+    } ]
+  }
+}
\ No newline at end of file
diff --git a/integration-tests/export/subject/fast-pipeline.hpl 
b/integration-tests/export/subject/fast-pipeline.hpl
new file mode 100644
index 0000000000..928d9ab9cf
--- /dev/null
+++ b/integration-tests/export/subject/fast-pipeline.hpl
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>fast-pipeline</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description/>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/04/20 00:00:00.000</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/04/20 00:00:00.000</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+  </order>
+  <transform>
+    <name>Generate rows</name>
+    <type>RowGenerator</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <fields>
+    </fields>
+    <interval_in_ms>5000</interval_in_ms>
+    <last_time_field>FiveSecondsAgo</last_time_field>
+    <limit>1</limit>
+    <never_ending>N</never_ending>
+    <row_time_field>now</row_time_field>
+    <attributes/>
+    <GUI>
+      <xloc>160</xloc>
+      <yloc>96</yloc>
+    </GUI>
+  </transform>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/integration-tests/export/subject/fast-workflow.hwf 
b/integration-tests/export/subject/fast-workflow.hwf
new file mode 100644
index 0000000000..ce63132490
--- /dev/null
+++ b/integration-tests/export/subject/fast-workflow.hwf
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>fast-workflow</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description/>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2026/04/20 00:00:00.000</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2026/04/20 00:00:00.000</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <DayOfMonth>1</DayOfMonth>
+      <hour>12</hour>
+      <intervalMinutes>60</intervalMinutes>
+      <intervalSeconds>0</intervalSeconds>
+      <minutes>0</minutes>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <weekDay>1</weekDay>
+      <parallel>N</parallel>
+      <xloc>128</xloc>
+      <yloc>80</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Success</name>
+      <description/>
+      <type>SUCCESS</type>
+      <attributes/>
+      <parallel>N</parallel>
+      <xloc>288</xloc>
+      <yloc>80</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>Success</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModel.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModel.java
index 37e6256498..6a8afd1420 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModel.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModel.java
@@ -168,8 +168,13 @@ public class DiagramExportDialogModel {
     DiagramExportOptions options = new DiagramExportOptions();
     options.setTargetFilename(filename);
     IDiagramExporter<?> exporter = getSelectedExporter();
-    if (exporter != null && exporter.getFormat() != null) {
+    if (exporter != null
+        && exporter.getFormat() != null
+        && StringUtils.isNotBlank(exporter.getFormat().getId())) {
       options.setFormat(exporter.getFormat().getId());
+    } else if (exporter != null) {
+      // No format: the export service also matches the exporter id, not the 
label shown here.
+      options.setFormat(exporter.getId());
     } else {
       options.setFormat(format);
     }
diff --git 
a/ui/src/test/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModelTest.java
 
b/ui/src/test/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModelTest.java
index 00e9dba505..83a29d535b 100644
--- 
a/ui/src/test/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModelTest.java
+++ 
b/ui/src/test/java/org/apache/hop/ui/hopgui/dialog/DiagramExportDialogModelTest.java
@@ -24,10 +24,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.core.diagram.BaseDiagramExporter;
 import org.apache.hop.core.diagram.DiagramExportFormat;
 import org.apache.hop.core.diagram.DiagramExportOptions;
+import org.apache.hop.core.diagram.DiagramExportResult;
 import org.apache.hop.core.diagram.DiagramExportService;
+import org.apache.hop.core.diagram.ExportContext;
 import org.apache.hop.core.diagram.IDiagramExporter;
+import org.apache.hop.core.diagram.IExportContext;
+import org.apache.hop.core.variables.Variables;
 import org.apache.hop.diagram.exporter.PipelineMermaidDiagramExporter;
 import org.apache.hop.diagram.exporter.PipelineSvgDiagramExporter;
 import org.apache.hop.pipeline.PipelineMeta;
@@ -36,6 +41,22 @@ import org.junit.jupiter.api.Test;
 
 class DiagramExportDialogModelTest {
 
+  /** A plugin exporter without a DiagramExportFormat: the dialog lists it by 
its name. */
+  static class NoFormatPipelineExporter extends 
BaseDiagramExporter<PipelineMeta> {
+    NoFormatPipelineExporter() {
+      id = "test-no-format";
+      name = "Plain Text Diagram";
+      fileExtension = "txt";
+      supportedSubjectTypes = new Class<?>[] {PipelineMeta.class};
+    }
+
+    @Override
+    public DiagramExportResult export(
+        PipelineMeta subject, DiagramExportOptions options, IExportContext 
context) {
+      return DiagramExportResult.success(options.getTargetFilename(), "plain", 
"text/plain");
+    }
+  }
+
   @BeforeAll
   static void init() throws Exception {
     HopClientEnvironment.init();
@@ -115,4 +136,27 @@ class DiagramExportDialogModelTest {
     assertNotNull(model.getFormatNames(null, null));
     assertNotNull(model.toOptions());
   }
+
+  @Test
+  void testExportWithExporterWithoutFormat() throws Exception {
+    NoFormatPipelineExporter noFormat = new NoFormatPipelineExporter();
+    DiagramExportService.getInstance().registerStaticExporter(noFormat);
+    try {
+      PipelineMeta pipelineMeta = new PipelineMeta();
+      DiagramExportDialogModel model = new 
DiagramExportDialogModel(pipelineMeta, null);
+      assertTrue(model.getFormatNames(null, null).contains("Plain Text 
Diagram"));
+
+      model.setFormat("Plain Text Diagram");
+      DiagramExportOptions options = model.toOptions();
+      assertEquals("test-no-format", options.getFormat());
+
+      IExportContext context =
+          new ExportContext(new Variables(), null, null, 
IExportContext.ExportEnvironment.TEST);
+      DiagramExportResult result =
+          DiagramExportService.getInstance().export(pipelineMeta, options, 
context);
+      assertEquals("plain", result.getContent());
+    } finally {
+      DiagramExportService.getInstance().unregisterStaticExporter(noFormat);
+    }
+  }
 }

Reply via email to