nullToFailure

fun <T> nullToFailure(    value: T?,     key: Metadata.Key<T>,     optional: Boolean): Validation<T>

For a non-existing attribute, a Scala Expression evaluates to a Failure, which may then be ignored in com.github.phisgr.gatling.grpc.HeaderPair.mutateMetadata.

Translating to the Java API, a Failure corresponds to throwing an exception. But for a simple null value we can skip the throw and catch.