You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "RichardLiu2001 (via GitHub)" <gi...@apache.org> on 2025/02/08 01:04:59 UTC
[PR] add check for slashless metadata paths [polaris]
RichardLiu2001 opened a new pull request, #968:
URL: https://github.com/apache/polaris/pull/968
<!--
Possible security vulnerabilities: STOP here and contact security@apache.org instead!
Please update the title of the PR with a meaningful message - do not leave it "empty" or "generated"
Please update this summary field:
The summary should cover these topics, if applicable:
* the motivation for the change
* a description of the status quo, for example the current behavior
* the desired behavior
* etc
PR checklist:
- Do a self-review of your code before opening a pull request
- Make sure that there's good test coverage for the changes included in this PR
- Run tests locally before pushing a PR (./gradlew check)
- Code should have comments where applicable. Particularly hard-to-understand
areas deserve good in-line documentation.
- Include changes and enhancements to the documentation (in site/content/in-dev/unreleased)
- For Work In Progress Pull Requests, please use the Draft PR feature.
Make sure to add the information BELOW this comment.
Everything in this comment will NOT be added to the PR description.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] add check for slashless metadata paths [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1947391846
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
The presence of a slash does not mean the path is full, e.g. `../relative`
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
+ metadataFileLocation);
+
// Throw an exception if this table already exists in the catalog.
if (tableExists(identifier)) {
throw new AlreadyExistsException("Table already exists: %s", identifier);
}
- String locationDir = metadataFileLocation.substring(0, metadataFileLocation.lastIndexOf("/"));
+ String locationDir = metadataFileLocation.substring(0, lastSlashIndex);
Review Comment:
What if `metadataFileLocation` is `s3://my-bucket`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: check for slashless metadata paths [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1951982049
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
To be clear, I don't think making this check for an absolute path is strictly a blocker here; we can (should?) file an issue to track that if need be. But let's please try to swiftly get rid of the 500
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
To be clear, I don't think making this check for an absolute path is strictly a blocker here; we can file an issue to track that if need be. But let's please try to swiftly get rid of the 500
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: check for slashless metadata paths [polaris]
Posted by "RichardLiu2001 (via GitHub)" <gi...@apache.org>.
RichardLiu2001 commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1953152861
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
Updated the message to be less ambiguous
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] add check for slashless metadata paths [polaris]
Posted by "RichardLiu2001 (via GitHub)" <gi...@apache.org>.
RichardLiu2001 commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1949746486
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
+ metadataFileLocation);
+
// Throw an exception if this table already exists in the catalog.
if (tableExists(identifier)) {
throw new AlreadyExistsException("Table already exists: %s", identifier);
}
- String locationDir = metadataFileLocation.substring(0, metadataFileLocation.lastIndexOf("/"));
+ String locationDir = metadataFileLocation.substring(0, lastSlashIndex);
Review Comment:
Since there is no `.metadata.json` in the file name, that would fail the file name format checks in https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/TableMetadataParser.java#L68 when we try to read the metadata file, giving a 400.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: check for slashless metadata paths [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1951981322
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
Yeah, but it is kind of misleading to check for condition X and then print an error message saying condition (X + Y) is not met.
How about...
```
Invalid metadata file location; metadata file location should be absolute and must contain `/`: %s
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] add check for slashless metadata paths [polaris]
Posted by "RichardLiu2001 (via GitHub)" <gi...@apache.org>.
RichardLiu2001 commented on code in PR #968:
URL: https://github.com/apache/polaris/pull/968#discussion_r1949740733
##########
service/common/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -309,12 +309,18 @@ public Table registerTable(TableIdentifier identifier, String metadataFileLocati
metadataFileLocation != null && !metadataFileLocation.isEmpty(),
"Cannot register an empty metadata file location as a table");
+ int lastSlashIndex = metadataFileLocation.lastIndexOf("/");
+ Preconditions.checkArgument(
+ lastSlashIndex != -1,
+ "Invalid metadata file location: %s, must be a full path to a file",
Review Comment:
Right, but this indicates the _absence_ of a slash, which means the path is not full.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: check for slashless metadata paths [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard merged PR #968:
URL: https://github.com/apache/polaris/pull/968
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org