{"record":{"id":"dfb389cd89bb4028","repo":"karatelabs/karate","slug":"failed-to-write-xml-for","errorCode":null,"errorMessage":"Failed to write xml for {}: {}","messagePattern":"Failed to write xml for (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/output/JunitXmlWriter.java","lineNumber":101,"sourceCode":"     */\n    public static String serializeFeature(FeatureResult result) {\n        return featureToXml(result);\n    }\n\n    /** File name this feature's output is written under. */\n    public static String fileNameFor(FeatureResult result) {\n        return result.getFeature().getResource().getPackageQualifiedName() + \".xml\";\n    }\n\n    /** Write pre-serialized content. Safe after the source result has been released. */\n    public static void writeSerialized(String fileName, String content, Path outputDir) {\n        try {\n            if (!Files.exists(outputDir)) {\n                Files.createDirectories(outputDir);\n            }\n            Files.writeString(outputDir.resolve(fileName), content);\n        } catch (Exception e) {\n            logger.warn(\"Failed to write xml for {}: {}\", fileName, e.getMessage());\n        }\n    }\n\n    public static void writeFeature(FeatureResult result, Path outputDir) {\n        try {\n            if (!Files.exists(outputDir)) {\n                Files.createDirectories(outputDir);\n            }\n\n            String fileName = result.getFeature().getResource().getPackageQualifiedName() + \".xml\";\n            Path xmlPath = outputDir.resolve(fileName);\n            String xml = featureToXml(result);\n            Files.writeString(xmlPath, xml);\n            logger.debug(\"JUnit XML written: {}\", xmlPath);\n        } catch (Exception e) {\n            logger.warn(\"Failed to write JUnit XML for {}: {}\", result.getDisplayName(), e.getMessage());\n        }\n    }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/output/JunitXmlWriter.java#L83-L119","documentation":"JunitXmlWriter.writeSerialized() creates the output directory if needed and writes the pre-serialized XML string to the given file name. Failures (directory creation or Files.writeString) are caught and logged as a warning naming the target file, leaving the run unaffected but the XML file missing.","triggerScenarios":"Exception creating outputDir or writing fileName — permission denied, path is a file, disk full, or invalid characters in fileName for the target filesystem.","commonSituations":"Read-only CI workspace; outputDir collides with an existing file; disk quota exceeded during large suites; fileName derived from a feature name containing filesystem-illegal characters.","solutions":["Verify the output directory path is writable and not occupied by a regular file","Free disk space / raise quota on the target volume","Sanitize or shorten the file name if it contains illegal or overly long characters","Check process permissions (chown/chmod) on the output directory"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Path xml = outputDir.resolve(fileName);\nif (Files.exists(xml) && Files.isDirectory(xml))\n    throw new IllegalStateException(\"XML path occupied by a directory: \" + xml);\nFiles.createDirectories(outputDir);","typeGuard":null,"tryCatchPattern":"try {\n    Files.createDirectories(outputDir);\n    Files.writeString(outputDir.resolve(fileName), content);\n} catch (Exception e) {\n    logger.warn(\"Failed to write xml for {}: {}\", fileName, e.getMessage(), e);\n}","preventionTips":["Sanitize feature-derived file names for the target filesystem","Keep file names within filesystem length limits","Check writability and free space before large suites"],"tags":["junit-xml","filesystem","file-write"],"backgroundTag":"file-write-failed","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}