Skip to content

fix: handle missing format-version in NewManifestReader for v1 manifests#868

Open
rockwotj wants to merge 1 commit intoapache:mainfrom
rockwotj:fix/manifest-reader-missing-format-version
Open

fix: handle missing format-version in NewManifestReader for v1 manifests#868
rockwotj wants to merge 1 commit intoapache:mainfrom
rockwotj:fix/manifest-reader-missing-format-version

Conversation

@rockwotj
Copy link
Copy Markdown
Contributor

Problem

NewManifestReader in manifest.go calls strconv.Atoi unconditionally on metadata["format-version"]. The Java Iceberg library omits this key from v1 manifest file Avro OCF headers — format-version is optional for v1 per the spec. When iceberg-go reads those files, metadata["format-version"] returns nil → empty string → Atoi("") → error:

manifest file's 'format-version' metadata is invalid: strconv.Atoi: parsing "": invalid syntax

Fix

Default formatVersion to 1 and only parse the metadata key when it is present. This matches the spec (format-version is optional for v1, required for v2+) and the same pattern already used in ReadManifestList since #826.

The existing formatVersion != file.Version() check below is unaffected and still catches real version mismatches.

Testing

Added TestNewManifestReaderMissingFormatVersion: writes a v1 manifest Avro file without the format-version metadata key (simulating Java Iceberg output) and verifies NewManifestReader succeeds and reports version 1.

Related

  • Follows the same pattern as fix(manifest): default to v1 files #826 which fixed ReadManifestList
  • Spec reference: format/spec.md Avro manifest file metadata table — format-version is optional for v1, required for v2

The Java Iceberg library omits the optional format-version metadata key
from v1 manifest file Avro OCF headers. NewManifestReader was calling
strconv.Atoi unconditionally on the empty string, causing a parse error.

Default to version 1 when the key is absent, matching the spec
(format-version is optional for v1, required for v2+) and the same
pattern used in ReadManifestList since apache#826.

Fixes apache#416
@rockwotj rockwotj requested a review from zeroshade as a code owner April 10, 2026 13:36
Copy link
Copy Markdown
Contributor

@laskoviymishka laskoviymishka left a comment

Choose a reason for hiding this comment

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

Nice catch!

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