DNSPolicy ProviderRefs Empty String Bypass
#468 aperta il 19 mag 2026
Metriche repository
- Star
- (10 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Describe the bug
The DNSPolicy creation form allows submission of an invalid providerRefs array containing an empty string. This occurs when a user types a value into the "Provider Refs" input field and subsequently clears it. The frontend form validation only checks if the array length is greater than 0, bypassing the required field validation and generating an invalid Kubernetes resource.
To Reproduce
- Go to 'Kuadrant -> Policies -> DNS' in the OpenShift Console.
- Click on 'Create DNS Policy'.
- Scroll down to the 'Provider Refs' input field.
- Type any character (e.g., 'aws') into the input field.
- Delete the text so the input field is completely empty.
- Fill in the remaining required fields (Policy Name, Target Gateway).
- Notice that the 'Create' button remains enabled. Click it and see the K8s API validation error.
Expected behavior
The form validation should detect that the providerRefs name is an empty string and correctly disable the 'Create' button.
Additional context
In KuadrantDNSPolicyCreatePage.tsx, the onChange handler wraps the cleared input into an array [{ name: "" }]. The form validation expression providerRefs.length > 0 evaluates to true because the array has a length of 1, ignoring the fact that the actual name value is an empty string.