quarkusio/quarkus · error · IllegalArgumentException

Extension name cannot be null

Error message

Extension name cannot be null

What it means

Thrown by CloudEventV1.getAttribute for any attribute name other than the standard CloudEvents V1 attributes (specversion, id, source, type, datacontenttype, dataschema, subject, time) — the switch's default branch. This record's message ('Extension name cannot be null') comes from the getExtension path: the given name is treated as a CloudEvents extension attribute, and the registry of extension name/value pairs has no entry (null extension name) for it, so the lookup rejects the unknown attribute.

Source

Thrown at extensions/funqy/funqy-amazon-lambda/runtime/src/main/java/io/quarkus/funqy/lambda/model/cloudevents/CloudEventV1.java:163

    public Object getAttribute(final String attributeName) throws IllegalArgumentException {
        return switch (attributeName) {
            case "specversion" -> getSpecVersion();
            case "id" -> getId();
            case "source" -> getSource();
            case "type" -> getType();
            case "datacontenttype" -> getDataContentType();
            case "dataschema" -> getDataSchema();
            case "subject" -> getSubject();
            case "time" -> getTime();
            default -> throw new IllegalArgumentException(
                    "The specified attribute name \"" + attributeName + "\" is not specified in version v1.");
        };
    }

    @Override
    public Object getExtension(final String s) {
        if (s == null) {
            throw new IllegalArgumentException("Extension name cannot be null");
        }
        return this.extensions.get(s);
    }

    @Override
    public Set<String> getExtensionNames() {
        return this.extensions.keySet();
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check for null (and blank) before calling getExtension
  2. Provide a default extension name when the source is optional

Example fix

// before
Object ext = event.getExtension(configExtName); // may be null
// after
Object ext = configExtName == null ? null : event.getExtension(configExtName);
Defensive patterns

Strategy: validation

Validate before calling

if (extensionName != null && !extensionName.isBlank()) {
    value = event.getExtension(extensionName);
}

Type guard

boolean isValidExtensionName(String s) {
    return s != null && !s.isBlank();
}

Try / catch

try {
    value = event.getExtension(name);
} catch (IllegalArgumentException e) {
    value = null;
}

Prevention

When it happens

Trigger: Calling getExtension(null), e.g. when the extension name comes from an unset config value, a missing header, or an unvalidated map key.

Common situations: Dynamically reading CloudEvent extension attributes from request headers where the header is absent; passing a variable that was never initialized.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/7457c07e8f3fc5f7. Report an issue: GitHub.