You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "fallintoplace (via GitHub)" <gi...@apache.org> on 2026/07/25 15:34:34 UTC
[PR] fix: reject malformed metadata file versions [iceberg-cpp]
fallintoplace opened a new pull request, #846:
URL: https://github.com/apache/iceberg-cpp/pull/846
When writing new table metadata, C++ extracts the version segment from the current metadata filename with `std::from_chars`. The parse result is currently ignored, so a filename such as `00010x-...metadata.json` is treated as version 10 and the next file is written as version 11.
The Java implementation treats any malformed or out-of-range version segment as unparseable and starts the generated filename at version 0. Match that behavior by requiring `from_chars` to consume the complete segment successfully. Regression coverage includes trailing characters, overflow, and an empty segment through the public metadata write path.
Tested with:
- `arrow_test --gtest_filter=MetadataIOTest.WriteMetadataWithBase`
- full CTest suite (17 test binaries)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: reject malformed metadata file versions [iceberg-cpp]
Posted by "evindj (via GitHub)" <gi...@apache.org>.
evindj commented on code in PR #846:
URL: https://github.com/apache/iceberg-cpp/pull/846#discussion_r3651116335
##########
src/iceberg/table_metadata.cc:
##########
@@ -517,11 +517,18 @@ int32_t TableMetadataUtil::ParseVersionFromLocation(std::string_view metadata_lo
size_t version_start = metadata_location.find_last_of('/') + 1;
size_t version_end = metadata_location.find('-', version_start);
+ if (version_end == std::string::npos) {
+ return -1;
+ }
+
int32_t version = -1;
- if (version_end != std::string::npos) {
- std::from_chars(metadata_location.data() + version_start,
- metadata_location.data() + version_end, version);
+ const auto* version_begin = metadata_location.data() + version_start;
+ const auto* version_limit = metadata_location.data() + version_end;
+ const auto [ptr, ec] = std::from_chars(version_begin, version_limit, version);
+ if (ec != std::errc{} || ptr != version_limit) {
+ return -1;
Review Comment:
This is a non blocking comment (especially given that this is a private method) but I wonder if we should change ```ParseVersionFromLocation()``` to return ```Result<>``` to ensure that callers explicit have to check for errors and act accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: reject malformed metadata file versions [iceberg-cpp]
Posted by "fallintoplace (via GitHub)" <gi...@apache.org>.
fallintoplace commented on code in PR #846:
URL: https://github.com/apache/iceberg-cpp/pull/846#discussion_r3651166829
##########
src/iceberg/table_metadata.cc:
##########
@@ -517,11 +517,18 @@ int32_t TableMetadataUtil::ParseVersionFromLocation(std::string_view metadata_lo
size_t version_start = metadata_location.find_last_of('/') + 1;
size_t version_end = metadata_location.find('-', version_start);
+ if (version_end == std::string::npos) {
+ return -1;
+ }
+
int32_t version = -1;
- if (version_end != std::string::npos) {
- std::from_chars(metadata_location.data() + version_start,
- metadata_location.data() + version_end, version);
+ const auto* version_begin = metadata_location.data() + version_start;
+ const auto* version_limit = metadata_location.data() + version_end;
+ const auto [ptr, ec] = std::from_chars(version_begin, version_limit, version);
+ if (ec != std::errc{} || ptr != version_limit) {
+ return -1;
Review Comment:
I considered that, but a parse failure is intentionally handled by starting at version 0, which matches the Java behavior. Returning the error from `Write` would change that fallback. Since this is a private helper with one caller and the `-1` behavior is documented, I think keeping the sentinel is simpler here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: reject malformed metadata file versions [iceberg-cpp]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac merged PR #846:
URL: https://github.com/apache/iceberg-cpp/pull/846
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org