Copilot commented on code in PR #1070:
URL: https://github.com/apache/iceberg-cpp/pull/1070#discussion_r4436206264


##########
src/iceberg/table_metadata.cc:
##########
@@ -748,7 +767,8 @@ Status 
TableMetadataBuilder::Impl::AssignUUID(std::string_view uuid) {
 
 Status TableMetadataBuilder::Impl::UpgradeFormatVersion(int8_t 
new_format_version) {
   // Check that the new format version is supported
-  if (new_format_version > TableMetadata::kSupportedTableFormatVersion) {
+  if (new_format_version < 1 ||
+      new_format_version > TableMetadata::kSupportedTableFormatVersion) {

Review Comment:
   Upgrade versions are narrowed to `int8_t` before this check, so requests 
such as `260` or `-252` become `4` and silently upgrade the table to v4, where 
snapshot writes are unsupported. This affects the public builder and the 
`upgrade-format-version` decoder in `json_serde.cc:2167`. Keep version inputs 
wide through the builder/update APIs and JSON decoding, validate before 
narrowing, and add regression tests for these values.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to