{"record":{"id":"bd030ed64fc98bd9","repo":"karatelabs/karate","slug":"reportassets-named-name-is-null-or-empty","errorCode":null,"errorMessage":"ReportAssets.named: name is null or empty","messagePattern":"ReportAssets\\.named: name is null or empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/ReportAssets.java","lineNumber":89,"sourceCode":"    private final List<Page> pages = new ArrayList<>();\n    private final List<String> assets = new ArrayList<>();   // extra static files copied verbatim\n    private String ctaLabel;           // optional top-bar CTA override (label + href); default is the OSS upsell\n    private String ctaHref;\n\n    // Bound at registration time by Suite.registerReportAssets.\n    private ClassLoader classLoader;\n\n    /** One nav-page (or other slot) contribution. */\n    public record Page(String slot, String title, String href) {}\n\n    private ReportAssets(String name) {\n        this.name = name;\n    }\n\n    /** Start a spec for the ext registered under {@code name}. */\n    public static ReportAssets named(String name) {\n        if (name == null || name.isBlank()) {\n            throw new IllegalArgumentException(\"ReportAssets.named: name is null or empty\");\n        }\n        return new ReportAssets(name);\n    }\n\n    /** The JS entry registered in {@code alpine:init} (D5). Required. */\n    public ReportAssets js(String path) {\n        this.js = path;\n        return this;\n    }\n\n    /** Optional stylesheet, loaded if set. */\n    public ReportAssets css(String path) {\n        this.css = path;\n        return this;\n    }\n\n    /** Add a slot page contribution (e.g. {@code nav.pages}). */\n    public ReportAssets page(String slot, String title, String href) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/ReportAssets.java#L71-L107","documentation":"ReportAssets.named() creates a report-extension spec and requires a non-blank name to register the extension's JS entry under. A null or empty name is rejected immediately with an IllegalArgumentException.","triggerScenarios":"ReportAssets.named(null) or ReportAssets.named(\"\") or ReportAssets.named(\"   \") when registering a custom report extension.","commonSituations":"Name read from config/env that is unset; refactoring where a literal name was dropped; programmatically derived name from a plugin id that resolved to empty.","solutions":["Pass a non-blank string name to ReportAssets.named(...)","If the name comes from config, default it: name == null ? \"default-ext\" : name","Trim user-supplied values before passing them in"],"exampleFix":"// before\nReportAssets assets = ReportAssets.named(cfg.extName());\n// after\nString extName = cfg.extName();\nif (extName == null || extName.isBlank()) extName = \"my-ext\";\nReportAssets assets = ReportAssets.named(extName.trim());","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) throw new IllegalArgumentException(\"report ext name required\");\nReportAssets assets = ReportAssets.named(name.trim());","typeGuard":null,"tryCatchPattern":"try { return ReportAssets.named(name); } catch (IllegalArgumentException e) { log.error(\"Report ext name invalid: {}\", name); throw e; }","preventionTips":["Centralize extension names in constants","Trim and default any config/env-derived names","Never build names from possibly-empty collections (e.g. first element of empty list)"],"tags":["reporting","validation","argument"],"backgroundTag":"empty-required-field","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"}