{"record":{"id":"674dc6fd166c0a11","repo":"karatelabs/karate","slug":"failed-to-initialize-jsonl-event-stream","errorCode":null,"errorMessage":"Failed to initialize JSONL event stream: {}","messagePattern":"Failed to initialize JSONL event stream: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/Suite.java","lineNumber":557,"sourceCode":"        JsonLinesEventWriter jsonlWriter = null;\n        boolean jsonlEnabled = outputJsonLines;\n        if (!jsonlEnabled && bootBinding != null) {\n            for (Ext ext : bootBinding.getExts()) {\n                if (ext.requiresJsonlEvents()) {\n                    logger.info(\"JSONL event stream auto-enabled by ext: {}\", ext.getClass().getSimpleName());\n                    jsonlEnabled = true;\n                    break;\n                }\n            }\n        }\n        if (jsonlEnabled) {\n            jsonlWriter = new JsonLinesEventWriter(outputDir, env, threadCount);\n            try {\n                jsonlWriter.init();\n                // Add to a mutable copy for event firing\n                addJsonlListener(jsonlWriter);\n            } catch (Exception e) {\n                logger.warn(\"Failed to initialize JSONL event stream: {}\", e.getMessage());\n                jsonlWriter = null;\n            }\n        }\n\n        try {\n            // Notify listeners\n            // Reset the embed file sequence (001_, 002_, …) for THIS run, regardless of whether HTML\n            // reporting is on — embeds are externalized from the FEATURE_EXIT seam (see fireEvent) so the\n            // counter must restart even for a JSONL-only run.\n            HtmlReportWriter.resetEmbedCounter();\n\n            for (ResultListener listener : resultListeners) {\n                listener.onSuiteStart(this);\n            }\n\n            // Fire SUITE_ENTER event\n            fireEvent(SuiteRunEvent.enter(this));\n","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/Suite.java#L539-L575","documentation":"When a Suite runs, it initializes a JSONL (JSON Lines) event stream writer in the output directory to record run events. If initializing the writer throws (IO error creating the file, invalid output dir, environment mismatch), the suite logs this warning, sets the writer to null, and continues the run without the event stream — results are still produced, but no JSONL events.","triggerScenarios":"Suite.run() with outputDir set and JSONL writing enabled where JsonLinesEventWriter.init() fails: output dir does not exist and cannot be created, disk full, permissions, or constructor/validation of the writer throws.","commonSituations":"Running in a read-only container/CI workspace; target/ or output dir deleted concurrently; outputDir pointed outside a writable volume; version mismatch where env/threadCount values are invalid.","solutions":["Ensure the output directory exists and is writable by the test process before the run","Check disk space and quota on the volume holding target/karate output","Run with a fresh, empty output dir (or let Karate back it up) rather than a pre-created read-only path","If JSONL events are not needed, disable the event stream option so the warning does not appear"],"exampleFix":"// before: unwritable output dir\njava -jar karate.jar -o /proc/output\n// after\njava -jar karate.jar -o target/karate-reports","handlingStrategy":"validation","validationCode":"java.nio.file.Path out = java.nio.file.Path.of(outputDir);\njava.nio.file.Files.createDirectories(out);\nif (!java.nio.file.Files.isWritable(out))\n    throw new IllegalStateException(\"output dir not writable: \" + out);","typeGuard":null,"tryCatchPattern":"try {\n    new Suite(builder).run();\n} catch (Exception e) {\n    // JSONL init failures are only warnings; detect via missing events file afterwards\n    if (!java.nio.file.Files.exists(java.nio.file.Path.of(outputDir, \"karate-events.jsonl\")))\n        logger.warn(\"event stream was not created; results may lack event data\");\n}","preventionTips":["Create and verify the output directory is writable before Suite.run()","Ensure adequate disk space/quota on the volume holding target output","Avoid read-only container filesystems for the output path (mount a writable volume)","If events are not required, disable the JSONL stream explicitly rather than relying on the fallback"],"tags":["io","events","output"],"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"}