[#10164] fix(server): prevent NPE in createSchema when request is null#10187
[#10164] fix(server): prevent NPE in createSchema when request is null#10187Sarojini-T wants to merge 1 commit intoapache:mainfrom
Conversation
|
This is not a valid case, it will not happen in a normal case. Besides, all of the REST operations don't check the nullability of the incoming request in the processing logic (it will be handled by Jersey/Jackson); if this is the case, all should be fixed. |
Addresses review feedback from jerryshao
|
Addressed feedback from @jerryshao:
Updated in commit b5223a3 |
|
@jerryshao I verified this behavior in the current codebase, and null request bodies are actually reachable in REST handlers. TestMetalakeOperations#testCreateMetalakeWithNullRequest sends Entity.entity(null, MediaType.APPLICATION_JSON_TYPE) and passes, which means Jersey/Jackson does not universally reject this before resource logic. Without the guard in createSchema, we hit an NPE path (request.getName()). So this case is valid. But to double-check here, a higher-level test confirming the issue. The call is basically: As you can see from the test that returns an HTTP status of 500 when it should return 400 Bad Request with an ErrorResponse with code 1001 (ILLEGAL_ARGUMENTS_CODE) and type "IllegalArgumentException". |
What changes were proposed in this pull request?
Why are the changes needed?
Sending a null request body to createSchema causes a raw NullPointerException before the try-catch block, resulting in an inconsistent 500 error instead of a proper validation error.
Fix: #10164
Does this PR introduce any user-facing change?
No user-facing changes were introduced.
How was this patch tested?