Skip to content

OneOfValueProvider builders clobber value by calling all setters unconditionally #1569

Description

@ricardozanini

Bug

ReferenceableAuthenticationPolicyBuilder.build() and RetryBackoffBuilder.build() call all setters unconditionally. Since each setter assigns this.value = param, the last call (with null) overwrites the previously set value.

// ReferenceableAuthenticationPolicyBuilder.build()
policy.setAuthenticationPolicy(this.authenticationPolicy);       // sets value = authenticationPolicy ✓
policy.setAuthenticationPolicyReference(this.authenticationPolicyReference); // sets value = null ✗

This causes OneOfValueProvider.get() to return null, so SerializeHelper.serializeOneOf writes authentication: null in the serialized output — even though the authentication is correctly configured and works at runtime.

Same pattern in BaseTryTaskBuilder.RetryBackoffBuilder.build() with three setters.

Impact

Breaks YAML/JSON rendering in DevUI and editor validation for any workflow using inline authentication (OAuth2, Basic, Bearer, Digest, OIDC on endpoints).

Tracked in: quarkiverse/quarkus-flow#781

Fix

Add null guards, matching the pattern BasicAuthenticationPolicyBuilder, BearerAuthenticationPolicyBuilder, and DigestAuthenticationPolicyBuilder already use:

public ReferenceableAuthenticationPolicy build() {
    final ReferenceableAuthenticationPolicy policy = new ReferenceableAuthenticationPolicy();
    if (this.authenticationPolicyReference != null) {
        policy.setAuthenticationPolicyReference(this.authenticationPolicyReference);
    } else {
        policy.setAuthenticationPolicy(this.authenticationPolicy);
    }
    return policy;
}

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions