Improve YAML parsing robustness and handle null Avro types#202
Merged
Improve YAML parsing robustness and handle null Avro types#202
Conversation
snakeyaml throws IndexOutOfBoundsException when parsing malformed YAML via Dynamics.newFromYaml(). The call in estimateElementStatus() was outside the existing try/catch, causing the exception to propagate up through the JDBC layer and crash getPipelineStatus requests. - Wrap Dynamics.newFromYaml() in estimateElementStatus() with try/catch; return a default unready status on parse failure instead of propagating - Same fix in getElementConfiguration() which had the identical pattern - Add tests for both: malformed YAML returns unready status / empty map Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SnakeYAML throws ScannerException, ParserException, and ConstructorException when parsing malformed YAML in Kubernetes resource specs or annotations. Two call sites were unprotected: 1. Operator.isReady(String yaml) and Operator.isFailed(String yaml): the Dynamics.newFromYaml() call was outside the existing try/catch, so any parse error would propagate up and crash the SubscriptionReconciler (stack trace through SubscriptionReconciler.reconcile line 171 -> Operator.isReady line 180). 2. SubscriptionReconciler.fetchAttributes(String yaml): same unprotected Dynamics.newFromYaml() call, returns empty map on parse failure instead. The K8sPipelineElementStatusEstimator call site was already fixed in a prior commit; this commit adds additional tests covering ScannerException, ParserException, and ConstructorException for completeness. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…timator When Dynamics.newFromYaml() parses YAML without a metadata field, the resulting DynamicKubernetesObject has null metadata. Calling obj.getMetadata().getName() on it caused NPE in estimateElementStatus(). Guard against null metadata by returning an unready status early, consistent with how we handle other parse/retrieval failures. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Add null guard at entry to AvroConverter.rel() and explicit NULL type handling. When a null schema or NULL-typed schema is encountered, returns a proper SQL NULL type instead of throwing NPE. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- K8sPipelineElementStatusEstimator: downgrade YAML parse errors from ERROR to WARN — exceptions are caught and handled correctly, ERROR level was causing spurious automated tickets - Operator.isReady/isFailed: guard against null metadata and null namespace in K8s resource - SubscriptionReconciler.fetchAttributes: guard against null metadata; downgrade SQL validation errors to WARN level Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
srnand
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Improve YAML parsing robustness and handle null Avro types
The operator processes Kubernetes resource YAML that can be arbitrarily malformed — truncated, invalid mappings, duplicate document markers, or Java type tags. Several code paths were either throwing these exceptions to callers when they should have been handling them gracefully, or logging caught exceptions at ERROR level when WARN is more appropriate (since the code recovers successfully).
Additionally, AvroConverter did not handle Avro schemas with null types, causing NullPointerException during SQL planning for schemas with optional fields.
Changes
K8sPipelineElementStatusEstimator
Operator
SubscriptionReconciler
AvroConverter
Tests
New tests covering each scenario: