Skip to content

Fix CEL validation error when provider field is missing in VolumeSpec#1850

Open
gabrielm-splunk wants to merge 1 commit intodevelopfrom
fix-cel-validation-provider-field
Open

Fix CEL validation error when provider field is missing in VolumeSpec#1850
gabrielm-splunk wants to merge 1 commit intodevelopfrom
fix-cel-validation-provider-field

Conversation

@gabrielm-splunk
Copy link
Copy Markdown
Collaborator

Problem

After upgrading to v3.1.0, customers encountered validation errors when updating existing Standalone CRs that were created with previous versions:

The Standalone "standalone" is invalid: status.smartstore.volumes[0]: 
Invalid value: "object": no such key: provider evaluating rule: 
region is required when provider is aws

This error occurred because the CEL validation rule added in #1740 attempted to access self.provider without first checking if the field exists. In upgrade scenarios, status fields populated by older operator versions may not include the provider field, causing the validation to fail with "no such key: provider".

Root Cause

The original CEL validation rule was:

self.provider != 'aws' || size(self.region) > 0

This rule evaluates self.provider even when the field doesn't exist, violating CEL's requirement to check field existence with has() before accessing optional fields.

Solution

Updated the CEL validation rule in api/v4/common_types.go to:

!has(self.provider) || self.provider != 'aws' || (has(self.region) && size(self.region) > 0)

This change:

  1. First checks if provider field exists with !has(self.provider)
  2. If it doesn't exist, validation passes (allows backward compatibility)
  3. Only validates the AWS region requirement when provider is explicitly set to 'aws'
  4. Also checks has(self.region) before accessing the region field

Testing

Reproduced the issue by:

  1. Deployed v3.1.0 operator and CRDs to an EKS cluster
  2. Created a Standalone CR with the buggy v3.1.0 CRDs
  3. Attempted to patch the status with a volume object missing the provider field (simulating an upgrade scenario)
  4. Confirmed the error: The Standalone "standalone" is invalid: status.smartstore.volumes[0]: Invalid value: "object": no such key: provider evaluating rule: region is required when provider is aws
  5. Applied the fix (regenerated CRDs with the corrected validation rule)
  6. Verified the same patch operation succeeds without errors

Impact

  • Fixes: Upgrade path from pre-3.1.0 versions where status fields were populated without the provider field
  • Maintains: The validation requirement that AWS volumes must have a region
  • No impact: On new deployments as they will include the provider field

Checklist

  • Changes have been tested and validated
  • CRDs regenerated using make manifests
  • Commit includes Co-Authored-By for compliance

🤖 Generated with Claude Code

Comment thread docs/index.yaml
## Problem
After upgrading to v3.1.0, customers encountered validation errors when
updating existing Standalone CRs that were created with previous versions:

```
The Standalone "standalone" is invalid: status.smartstore.volumes[0]:
Invalid value: "object": no such key: provider evaluating rule:
region is required when provider is aws
```

This error occurred because the CEL validation rule added in #1740
attempted to access `self.provider` without first checking if the field
exists. In upgrade scenarios, status fields populated by older operator
versions may not include the `provider` field, causing the validation
to fail with "no such key: provider".

## Root Cause
The original CEL validation rule was:
```
self.provider != 'aws' || size(self.region) > 0
```

This rule evaluates `self.provider` even when the field doesn't exist,
violating CEL's requirement to check field existence with `has()` before
accessing optional fields.

## Solution
Updated the CEL validation rule to:
```
!has(self.provider) || self.provider != 'aws' || (has(self.region) && size(self.region) > 0)
```

This change:
1. First checks if `provider` field exists with `!has(self.provider)`
2. If it doesn't exist, validation passes (allows backward compatibility)
3. Only validates the AWS region requirement when provider is explicitly set to 'aws'
4. Also checks `has(self.region)` before accessing the region field

## Testing
Reproduced the issue by:
1. Creating a Standalone CR with the v3.1.0 CRDs
2. Patching the status to remove the provider field (simulating upgrade scenario)
3. Confirmed the error: "no such key: provider evaluating rule"
4. Applied the fix and verified the same operation succeeds

## Impact
- Fixes upgrade path from pre-3.1.0 versions where status fields were
  populated without the provider field
- Maintains the validation requirement that AWS volumes must have a region
- No impact on new deployments as they will include the provider field

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gabrielm-splunk gabrielm-splunk force-pushed the fix-cel-validation-provider-field branch from e3c9931 to 5e44be1 Compare April 21, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants