karatelabs/karate · error · IllegalArgumentException

ReportAssets.named: name is null or empty

Error message

ReportAssets.named: name is null or empty

What it means

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.

Solutions

  1. Pass a non-blank string name to ReportAssets.named(...)
  2. If the name comes from config, default it: name == null ? "default-ext" : name
  3. Trim user-supplied values before passing them in

Example fix

// before
ReportAssets assets = ReportAssets.named(cfg.extName());
// after
String extName = cfg.extName();
if (extName == null || extName.isBlank()) extName = "my-ext";
ReportAssets assets = ReportAssets.named(extName.trim());
Defensive patterns

Strategy: validation

Validate before calling

if (name == null || name.isBlank()) throw new IllegalArgumentException("report ext name required");
ReportAssets assets = ReportAssets.named(name.trim());

Try / catch

try { return ReportAssets.named(name); } catch (IllegalArgumentException e) { log.error("Report ext name invalid: {}", name); throw e; }

Prevention

When it happens

Trigger: ReportAssets.named(null) or ReportAssets.named("") or ReportAssets.named(" ") when registering a custom report extension.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/bd030ed64fc98bd9. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/core/ReportAssets.java:89

    private final List<Page> pages = new ArrayList<>();
    private final List<String> assets = new ArrayList<>();   // extra static files copied verbatim
    private String ctaLabel;           // optional top-bar CTA override (label + href); default is the OSS upsell
    private String ctaHref;

    // Bound at registration time by Suite.registerReportAssets.
    private ClassLoader classLoader;

    /** One nav-page (or other slot) contribution. */
    public record Page(String slot, String title, String href) {}

    private ReportAssets(String name) {
        this.name = name;
    }

    /** Start a spec for the ext registered under {@code name}. */
    public static ReportAssets named(String name) {
        if (name == null || name.isBlank()) {
            throw new IllegalArgumentException("ReportAssets.named: name is null or empty");
        }
        return new ReportAssets(name);
    }

    /** The JS entry registered in {@code alpine:init} (D5). Required. */
    public ReportAssets js(String path) {
        this.js = path;
        return this;
    }

    /** Optional stylesheet, loaded if set. */
    public ReportAssets css(String path) {
        this.css = path;
        return this;
    }

    /** Add a slot page contribution (e.g. {@code nav.pages}). */
    public ReportAssets page(String slot, String title, String href) {

View on GitHub (pinned to a22eb90246)