Skip to content

Conversation

@KyleLin0927
Copy link
Contributor

@KyleLin0927 KyleLin0927 commented May 24, 2025

What changes were proposed in this pull request?

Add validation: throw error if StorageLocation is null or blank Storage location for name '" + e.getKey() + "' must not be null or blank

Why are the changes needed?

Fixes #7190

Does this PR introduce any user-facing change?

No. APIs and behavior are unchanged, only error messages for invalid input are clearer.

How was this patch tested?

  • Added new unit tests.
  • Verified with ./gradlew clean build.

@KyleLin0927
Copy link
Contributor Author

@mchades I have simplified the logic. throwing an exception if any blank data is found. I’ve also updated my unit tests accordingly and reverted the changes made to the web UI (no longer needed).

}
Map<String, Path> schemaPaths =
getAndCheckSchemaPaths(schemaIdent.name(), schemaEntity.properties());
if (schemaPaths.isEmpty() && storageLocations.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

only need to change this line to:
if (schemaPaths.isEmpty() && (storageLocations.isEmpty() || storageLocations.values().stream().allMatch(StringUtils::isBlank)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for suggestion. I applied this change, but during testing, I encountered a NullPointerException when the input storageLocations map contained a mix of valid values and blank/null values.

Copy link
Contributor

Choose a reason for hiding this comment

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

NPE from where?

Copy link
Contributor Author

@KyleLin0927 KyleLin0927 May 26, 2025

Choose a reason for hiding this comment

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

You may refer to the unit test I added in this PR (TestHadoopCatalogOperations.java line 1559) If I only use

if (schemaPaths.isEmpty() && (storageLocations.isEmpty() || storageLocations.values().stream().allMatch(StringUtils::isBlank)))

and the storageLocations input contains both a valid entry and a blank value, it will still trigger an NPE in calculateFilesetPaths. If you think this test is not appropriate, I will remove it.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

let me think it over.

Copy link
Contributor

Choose a reason for hiding this comment

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

@KyleLin0927 You can use the code from this commit and complete the tests.

mchades@926f49e

@KyleLin0927
Copy link
Contributor Author

@mchades Thansks for providing the code. I’ve completed the updates accordingly, but I noticed that the changes introduced caused the testCreateSchemaWithEmptyCatalogLocation fail. I made some adjustments to address the issue (you can find it in the second commit)

null));
Assertions.assertEquals("Location name must not be blank", exception.getMessage());

// empty location in catalog location
Copy link
Contributor

Choose a reason for hiding this comment

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

could you plz also test the cases that:

  1. empty location in the schema location
  2. empty fileset storage location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mchades mchades added the branch-0.9 Automatically cherry-pick commit to branch-0.9 label Jun 5, 2025
Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your contributions!

Let's wait for the CI pass.

@mchades mchades merged commit 8867d82 into apache:main Jun 5, 2025
30 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 5, 2025
…HadoopCatalogOperations (#7238)

### What changes were proposed in this pull request?

Add validation: throw error if StorageLocation is null or blank `Storage
location for name '" + e.getKey() + "' must not be null or blank`

### Why are the changes needed?

Fixes #7190

### Does this PR introduce any user-facing change?

No. APIs and behavior are unchanged, only error messages for invalid
input are clearer.

### How was this patch tested?

- Added new unit tests.
- Verified with `./gradlew clean build`.
jerryshao pushed a commit to jerryshao/gravitino that referenced this pull request Jul 8, 2025
…ns in HadoopCatalogOperations (apache#7238)

### What changes were proposed in this pull request?

Add validation: throw error if StorageLocation is null or blank `Storage
location for name '" + e.getKey() + "' must not be null or blank`

### Why are the changes needed?

Fixes apache#7190

### Does this PR introduce any user-facing change?

No. APIs and behavior are unchanged, only error messages for invalid
input are clearer.

### How was this patch tested?

- Added new unit tests.
- Verified with `./gradlew clean build`.
vishnu-chalil pushed a commit to vishnu-chalil/gravitino that referenced this pull request Jul 14, 2025
…ns in HadoopCatalogOperations (apache#7238)

### What changes were proposed in this pull request?

Add validation: throw error if StorageLocation is null or blank `Storage
location for name '" + e.getKey() + "' must not be null or blank`

### Why are the changes needed?

Fixes apache#7190

### Does this PR introduce any user-facing change?

No. APIs and behavior are unchanged, only error messages for invalid
input are clearer.

### How was this patch tested?

- Added new unit tests.
- Verified with `./gradlew clean build`.
hdygxsj pushed a commit to hdygxsj/gravitino that referenced this pull request Jul 15, 2025
…ns in HadoopCatalogOperations (apache#7238)

### What changes were proposed in this pull request?

Add validation: throw error if StorageLocation is null or blank `Storage
location for name '" + e.getKey() + "' must not be null or blank`

### Why are the changes needed?

Fixes apache#7190

### Does this PR introduce any user-facing change?

No. APIs and behavior are unchanged, only error messages for invalid
input are clearer.

### How was this patch tested?

- Added new unit tests.
- Verified with `./gradlew clean build`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch-0.9 Automatically cherry-pick commit to branch-0.9

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] empty storageLocation throw NPE

2 participants