fix: properly propagate errors in MetricsConfig validation#465
Merged
wgtmac merged 1 commit intoapache:mainfrom Dec 31, 2025
Merged
fix: properly propagate errors in MetricsConfig validation#465wgtmac merged 1 commit intoapache:mainfrom
wgtmac merged 1 commit intoapache:mainfrom
Conversation
fa69b59 to
7071acb
Compare
The previous error handling in VerifyReferencedColumns treated all failures the same way. When FindFieldByName() failed, both actual errors (e.g., internal failures during name resolution) and simple "field not found" cases would return the same generic validation error message, losing important error context. FindFieldByName() returns Result<optional<reference_wrapper>>, which can represent three states: 1. Error during lookup (Result contains error) 2. Lookup succeeded but field not found (Result contains empty optional) 3. Lookup succeeded and field found (Result contains optional with value) The original code combined states 1 and 2: if (!field.has_value() || !field.value().has_value()) Changed to use ICEBERG_ASSIGN_OR_RAISE to separate error propagation from the "not found" check: ICEBERG_ASSIGN_OR_RAISE(auto field, schema.FindFieldByName(...)); if (!field.has_value()) The macro unwraps the Result, propagating any errors immediately, then assigns the optional to field. The subsequent has_value() check verifies if the optional contains a value, maintaining the same functionality while properly handling errors. This pattern is already used elsewhere in the codebase (e.g., table_metadata.cc:80-85).
7071acb to
5bb61ea
Compare
Contributor
|
|
wgtmac
approved these changes
Dec 31, 2025
Member
Agreed. I think they are different errors and should be handled differently. |
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.
The previous code had a logic error when checking the result of FindFieldByName(). It used:
if (!field.has_value() || !field.value().has_value())
This was incorrect because:
Fixed by using ICEBERG_ASSIGN_OR_RAISE to properly propagate any errors from FindFieldByName(), then checking if the returned optional contains a value. This matches the pattern used throughout the rest of the codebase and ensures errors are properly handled.