{"record":{"id":"d868d6f8919bfce1","repo":"karatelabs/karate","slug":"registerreportassets-assets-is-null","errorCode":null,"errorMessage":"registerReportAssets: assets is null","messagePattern":"registerReportAssets: assets is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/Suite.java","lineNumber":800,"sourceCode":"    public Object getGlobal(String name) {\n        return globals.get(name);\n    }\n\n    /** Immutable view of all ext globals, in registration order. */\n    public Map<String, Object> getGlobals() {\n        return Collections.unmodifiableMap(globals);\n    }\n\n    /**\n     * Register an ext's report-asset contribution. Called by an {@link Ext} from\n     * {@link Ext#onBoot(Suite)} with a fluent {@link ReportAssets} spec, e.g.\n     * {@code suite.registerReportAssets(ReportAssets.named(\"image\").js(\"static/ext.js\"), getClass().getClassLoader())}.\n     * Validates the spec against the classloader (referenced resources must exist);\n     * any failure throws and so fails the Suite loud at boot (see EXT.md § Report assets).\n     */\n    public void registerReportAssets(ReportAssets assets, ClassLoader classLoader) {\n        if (assets == null) {\n            throw new IllegalArgumentException(\"registerReportAssets: assets is null\");\n        }\n        assets.validateAndBind(classLoader);\n        reportAssets.put(assets.name(), assets);\n    }\n\n    /** Immutable view of all registered ext report-asset specs, in registration order. */\n    public Map<String, ReportAssets> getReportAssets() {\n        return Collections.unmodifiableMap(reportAssets);\n    }\n\n    /**\n     * Contribute one KPI summary card to the summary-page hero (a key/value tile, e.g.\n     * {@code {label:'Coverage', value:'53%', sub:'8/15 endpoints'}}). Called by an {@link Ext}\n     * from {@link Ext#onShutdown()} (the values are post-run), which the run loop invokes before\n     * the report listener writes the summary, so cards are inlined into the page. Optional keys\n     * the renderer understands: {@code sub} (a second line), {@code href} (click-through), and\n     * {@code status} ({@code ok}/{@code warn}/{@code fail}, for accent colour).\n     */","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/Suite.java#L782-L818","documentation":"Suite.registerReportAssets(ReportAssets, ClassLoader) throws this IllegalArgumentException when the ReportAssets spec is null. Report assets are static JS/CSS/image resources bundled into ext reports; a null spec cannot be validated or bound, so the Suite fails loud at boot rather than producing a broken report later.","triggerScenarios":"Calling suite.registerReportAssets(null, classLoader), or passing a variable/expression that evaluated to null (e.g. a builder method chain that returned null, or a map lookup miss).","commonSituations":"Conditional asset registration code like assets == something ? null : ...; a helper method returning null when no assets configured; refactoring removed the ReportAssets.named(...) construction while the call site remained.","solutions":["Ensure a valid ReportAssets is constructed, e.g. ReportAssets.named(\"image\").js(\"static/ext.js\"), before calling","Guard the call site: only invoke registerReportAssets when the assets object is non-null","If assets come from config, fail early with a clear message when the configured spec cannot be built"],"exampleFix":"// before\nReportAssets assets = maybeBuildAssets();\nsuite.registerReportAssets(assets, getClass().getClassLoader());\n// after\nReportAssets assets = maybeBuildAssets();\nif (assets != null) {\n    suite.registerReportAssets(assets, getClass().getClassLoader());\n}","handlingStrategy":"type-guard","validationCode":"if (assets != null) suite.registerReportAssets(assets, classLoader);","typeGuard":"boolean hasAssets(ReportAssets a) { return a != null; }","tryCatchPattern":"try { suite.registerReportAssets(assets, cl); } catch (IllegalArgumentException e) { /* null assets: skip or fail boot with message */ }","preventionTips":["Never return null from asset-building helpers; return an empty ReportAssets","Construct assets with ReportAssets.named(...) directly at the call site","Guard conditional registrations with explicit null checks"],"tags":["java","reporting","null-check"],"backgroundTag":"null-argument","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}