Skip to content

fix: reject malformed metadata file versions - #846

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/reject-malformed-metadata-versions
Open

fix: reject malformed metadata file versions#846
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/reject-malformed-metadata-versions

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject malformed and out-of-range version segments in metadata filenames instead of accepting a valid numeric prefix
  • start generated metadata filenames at version 0 when the current version cannot be parsed, matching Java
  • add coverage for trailing characters, overflow, and an empty version segment through the metadata write path

Testing

  • arrow_test --gtest_filter=MetadataIOTest.WriteMetadataWithBase
  • full CTest suite (17 test binaries)

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants