You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ValidateKey does not validate the internal format of storage keys #2775
What happened:
The ValidateKey function in pkg/yurthub/storage/utils/validate.go only validates
that a storage.Key is non-nil/non-empty and has the correct concrete type
(via reflect.TypeOf). It does not validate the internal format of the key's
path (e.g. required segments, separators), as noted by an existing TODO comment:
// TODO: should also valid the key formatfuncValidateKey(key storage.Key, validKeyTypeinterface{}) error {
This means a key with a correct Go type but a malformed internal path
(e.g. missing segments, invalid GVR format) passes validation without error,
even though it would fail later when parsed (e.g. by disk.ExtractKeyBuildInfo).
What you expected to happen: ValidateKey (and ValidateKV) should also validate the internal format of
the key, so malformed keys are rejected early with a clear error, rather than
failing later/silently when the key is actually used.
How to reproduce it (as minimally and precisely as possible):
Construct a disk storage key with a malformed path, e.g.:
Observe that no error is returned, even though the path does not match
the documented disk key format: /<Component>/<Resource.Version.Group>/<Namespace>/<Name>
Anything else we need to know?:
I'd like to work on this — proposed approach:
Add an optional KeyFormatValidator interface (Validate() error) in pkg/yurthub/storage, separate from the existing minimal Key interface,
so this stays backward compatible for key types that don't need format
validation (e.g. ClusterInfoKey).
Implement Validate() on disk.storageKey, reusing the same parsing
rules already used in ExtractKeyBuildInfo.
Update ValidateKey in utils/validate.go to call Validate() via a
type assertion, when the key implements it.
Happy to open a PR with this change if the approach sounds good.
Environment:
OpenYurt version: main branch
Kubernetes version (use kubectl version): N/A (not a runtime issue, source-code level)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
fix(storage): add ValidateDiskKey to validate disk key format
fix(storage): add ValidateDiskKey to validate disk key format
mohammd-khalil commentedon Aug 30, 2026
hi bro @AruneshDwivedi
what are you doing ???
find issues and assign your pr .
close yours bro !!!
stale commentedon Dec 4, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.