Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBounds in FileFormat#fromFileName #12300

Open
1 of 3 tasks
rshkv opened this issue Feb 17, 2025 · 2 comments · May be fixed by #12301
Open
1 of 3 tasks

IndexOutOfBounds in FileFormat#fromFileName #12300

rshkv opened this issue Feb 17, 2025 · 2 comments · May be fixed by #12301
Labels
bug Something isn't working

Comments

@rshkv
Copy link
Contributor

rshkv commented Feb 17, 2025

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
@rshkv rshkv added the bug Something isn't working label Feb 17, 2025
@RussellSpitzer
Copy link
Member

Good catch, so I guess we need to just not do the check if the start is negative and not check in that case?

@rshkv
Copy link
Contributor Author

rshkv commented Feb 18, 2025

I think so, yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants