{"record":{"id":"bbfde83ac34b9ead","repo":"apache/seatunnel","slug":"failed-to-export-metadata","errorCode":null,"errorMessage":"Failed to export metadata","messagePattern":"Failed to export metadata","errorType":"exception","errorClass":"CommandExecuteException","httpStatus":null,"severity":"error","filePath":"seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/MetadataExportCommand.java","lineNumber":134,"sourceCode":"                    connectorsArray.add(connectorNode);\n                }\n            }\n\n            root.set(\"connectors\", connectorsArray);\n\n            if (args.isStdout()) {\n                System.out.println(mapper.writeValueAsString(root));\n            } else {\n                File outputFile = new File(args.getOutputPath());\n                mapper.writeValue(outputFile, root);\n                System.err.println(\n                        \"Exported \"\n                                + connectorsArray.size()\n                                + \" connectors to \"\n                                + outputFile.getAbsolutePath());\n            }\n        } catch (IOException e) {\n            throw new CommandExecuteException(\"Failed to export metadata\", e);\n        }\n    }\n\n    private ObjectNode exportConnector(\n            PluginIdentifier id, OptionRule rule, PluginType pluginType) {\n        ObjectNode node = mapper.createObjectNode();\n        node.put(\"name\", id.getPluginName());\n        node.put(\"type\", pluginType.getType());\n\n        // Required options — preserving the 4 subtypes\n        ArrayNode requiredArray = mapper.createArrayNode();\n        for (RequiredOption reqOpt : rule.getRequiredOptions()) {\n            String category = resolveCategory(reqOpt);\n            String expression = null;\n\n            if (reqOpt instanceof RequiredOption.ConditionalRequiredOptions) {\n                Expression expr =\n                        ((RequiredOption.ConditionalRequiredOptions) reqOpt).getExpression();","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/MetadataExportCommand.java#L116-L152","documentation":"MetadataExportCommand.execute writes the exported connector metadata (plugin identifiers, option rules) to the output JSON file. Any IOException encountered while creating or writing that file is rethrown as CommandExecuteException('Failed to export metadata', e). The export logic itself succeeded in enumerating connectors; the failure is purely on the output-file side.","triggerScenarios":"The --output path is unwritable (permission denied, read-only filesystem), its parent directory does not exist, the path is a directory, or disk is full while the Jackson writer flushes the connectors array.","commonSituations":"Running in a container as non-root writing to a root-owned path; typo in the output directory; overwriting a file locked or owned by another user; exporting to a mounted volume not yet mounted.","solutions":["Check the nested IOException cause for the exact filesystem reason.","Verify the output path's parent directory exists and is writable by the running user; create it or choose another path.","Check disk space and file permissions (ls -ld on the target directory).","If running in a container, ensure the volume is mounted and the user has write access."],"exampleFix":"// before\nseatunnel.sh -m --output /root/only/meta.json   # non-root user\n// after\nmkdir -p /tmp/seatunnel-meta\nseatunnel.sh -m --output /tmp/seatunnel-meta/meta.json","handlingStrategy":"validation","validationCode":"const dir = path.dirname(outputFile);\nif (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\nfs.accessSync(dir, fs.constants.W_OK); // throws early if unwritable","typeGuard":null,"tryCatchPattern":"try { exportMetadata(args); } catch (CommandExecuteException e) { if (e.getMessage().equals(\"Failed to export metadata\")) { log.error(\"Check output path/permissions/disk: \", e.getCause()); } else { throw e; } }","preventionTips":["Pre-create the output directory and verify write permissions","Avoid exporting to root-owned or read-only paths from non-root users","Check free disk space before large exports"],"tags":["io","file-write","metadata-export","cli"],"backgroundTag":"file-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}