-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Apache Iceberg version
main (development)
Query engine
No response
Please describe the bug 🐞
PropertyUtil.propertiesWithPrefix uses String.replaceFirst(prefix, "") to strip the prefix from matched keys. Since replaceFirst treats its first argument as a Java regex pattern, prefixes containing regex-special characters (e.g. [, (, +, $) cause incorrect behavior:
-
Silent mismatch: A prefix like
prefix[0].is valid regex where[0]matches char0and.matches any char. AfterstartsWithfiltering, the key always starts with the literal prefix, butreplaceFirstfails to match the regex at position 0, silently returning the full key instead of stripping the prefix. -
PatternSyntaxException: A prefix like
prefix[0.contains an unclosed character class, causingreplaceFirstto throwPatternSyntaxException.
The fix is to replace replaceFirst(prefix, "") with substring(prefix.length()), which is safe, explicit, and consistent with the startsWith(prefix) filter applied immediately before.
Discovered while investigating #15347.
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