-
Notifications
You must be signed in to change notification settings - Fork 18
fix: enhance manifest handling by validating and expanding YAML docum… #1022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances Kubernetes manifest handling by adding validation and expansion capabilities for kind: List manifests and non-dictionary YAML documents. The changes ensure that only valid manifest dictionaries are processed while expanding nested list structures.
Changes:
- Added a new
_expand_and_validate_manifestsmethod that recursively expandskind: Listmanifests, validates manifest types, and logs warnings for invalid documents - Updated four manifest processing methods (
apply_manifest_from_url,delete_manifest_from_url,apply_manifest_from_file,delete_manifest_from_file) to use the new validation and expansion logic - Added comprehensive unit tests covering valid manifests,
kind: List(including nested lists), non-dict/scalar/empty/None manifests, and invaliditemsfields
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/python/clients/kubernetes_client.py | Added _expand_and_validate_manifests method and integrated it into manifest processing methods to ensure only valid dictionaries are processed and kind: List manifests are properly expanded |
| modules/python/tests/clients/test_kubernetes_client.py | Added 9 comprehensive test cases covering various scenarios for the new manifest validation and expansion functionality |
| type(items).__name__ | ||
| ) | ||
| continue | ||
| logger.info("Expanding List manifest containing %d items", len(items)) |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This info-level log message for expanding List manifests may create excessive noise in logs, especially for large deployments or frequent manifest operations. Consider using debug level instead: logger.debug(...) to keep info logs focused on significant operations.
| logger.info("Expanding List manifest containing %d items", len(items)) | |
| logger.debug("Expanding List manifest containing %d items", len(items)) |
| } | ||
| ] | ||
|
|
||
| result = self.client._expand_and_validate_manifests(manifests) |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing private methods (prefixed with _) directly is generally discouraged as it couples tests to implementation details. While the extensive testing here is valuable, consider also adding tests that exercise this functionality through the public API methods (apply_manifest_from_url, etc.) to ensure the integration works correctly end-to-end.
This pull request improves the robustness and correctness of Kubernetes manifest handling by introducing a new method to validate and expand manifest documents, especially those using
kind: Listor containing non-dictionary YAML documents. The update ensures only valid manifest dictionaries are processed, and includes comprehensive tests for these scenarios.Manifest validation and expansion improvements:
_expand_and_validate_manifestsmethod tokubernetes_client.pyto recursively expandkind: Listmanifests and skip invalid or non-dictionary documents, logging appropriate warnings.apply_manifest_from_url,delete_manifest_from_url,apply_manifest_from_file, anddelete_manifest_from_fileto use_expand_and_validate_manifestsbefore applying or deleting manifests, ensuring only valid manifests are processed and allkind: Listitems are handled correctly. [1] [2] [3] [4]Testing enhancements:
test_kubernetes_client.pyto cover various scenarios for_expand_and_validate_manifests, including valid manifests,kind: List(including nested lists), non-dict/scalar/empty/None manifests, and invalid or missingitemsfields. Also added integration tests for manifest application from URLs with these edge cases.…ents