Skip to content

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

Open
gabrielm-splunk wants to merge 3 commits intodevelopfrom
fix-cel-validation-provider-field
Open

Fix CEL validation error when provider field is missing in VolumeSpec#1850
gabrielm-splunk wants to merge 3 commits 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

gabrielm-splunk and others added 3 commits April 16, 2026 14:27
Version 3.0.0 was inadvertently removed by automated PR (commit 1139fcf)
when 3.1.0 was added. Customers reported the version missing from
`helm search repo` results.

Changes:
- Restored 3.0.0 packaged chart from git tag
- Added 3.0.0 entries to docs/index.yaml for both splunk-enterprise and splunk-operator charts
- Chart digest: db5890e3bcc95f9ca7298873cc08b4a5d1ee86ccb4ad4e5334a0ab5d7a5fdb5e

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update index.yaml with correct SHA256 digests matching actual tarballs:
- splunk-enterprise-3.0.0: ae82f6c8edee4d827817fe6c9c6447c422a03c59595a0f6e779cef847a83b611
- splunk-operator-3.0.0: bd318b1f4022421a3fd429b186ca344c61d04a3c2bbdd5cc535d960773558e44

Resolves comment from vivekr-splunk on PR #1832

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
## 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>
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.

1 participant