Skip to content

IndexOutOfBounds in FileFormat#fromFileName #12300

Closed
@rshkv

Description

@rshkv

Apache Iceberg version

1.8.0 (latest release)

Query engine

None

Please describe the bug 🐞

FileFormat#fromFileName doesn't account for short file names here. When a file name is shorter than the longest file format extension (metadata.json), we get an error like this one:

begin -6, end 8, length 8
java.lang.StringIndexOutOfBoundsException: begin -6, end 8, length 8
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4604)
	at java.base/java.lang.String.substring(String.java:2707)
	at java.base/java.lang.String.subSequence(String.java:2745)
	at org.apache.iceberg.FileFormat.fromFileName(FileFormat.java:64)
	at org.apache.iceberg.FileFormatTest.fromFileName(FileFormatTest.java:40)

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions