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

Incorrect/unclear Error Message #5

Closed
jimmycal opened this issue Mar 12, 2017 · 5 comments
Closed

Incorrect/unclear Error Message #5

jimmycal opened this issue Mar 12, 2017 · 5 comments
Assignees

Comments

@jimmycal
Copy link

If passing an empty userID string to -

GetUserResponse user = identityService.getUser(GetUserRequest.builder().userId(event.getPrincipalId()).build());

The error message is

Exception in thread "main" com.oracle.bmc.model.BmcException: (400, InvalidParameter, false) Invalid parameter 'compartmentId' (opc-request-id: AC33DA26DDE6430ABC88BBF04DE73E3B/37632E5CB5C4465EA6C33DE3512F033A/6532C2AE95E44D74B7DD08166D755E0A)
at com.oracle.bmc.http.internal.ResponseHelper.throwIfNotSuccessful(ResponseHelper.java:91)
at com.oracle.bmc.http.internal.ResponseConversionFunctionFactory$ValidatingParseResponseFunction.apply(ResponseConversionFunctionFactory.java:87)
at com.oracle.bmc.http.internal.ResponseConversionFunctionFactory$ValidatingParseResponseFunction.apply(ResponseConversionFunctionFactory.java:83)
at com.oracle.bmc.identity.internal.http.GetUserConverter$1.apply(GetUserConverter.java:64)
at com.oracle.bmc.identity.internal.http.GetUserConverter$1.apply(GetUserConverter.java:57)
at com.oracle.bmc.identity.IdentityClient.getUser(IdentityClient.java:293)
at ListAuditEventsSinceDate.main(ListAuditEventsSinceDate.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

@priteshkp
Copy link
Member

Thanks, James. I'll pass this on to our service teams -- that message about compartmentId being wrong comes from the server.

@priteshkp
Copy link
Member

priteshkp commented Mar 22, 2017

Hey James,
ok, so we figured out what's happening and it's not a server bug, just an issue with how the request ends up being formulated on the client side.

When fetching a user, the SDK does:
GET /user/{userId}

When you provide an empty string, it does:
GET /user/

Which is the same path as doing a ListUsers call, so the server responds with an error saying compartmentId is missing because ListUsers requires it. There's unfortunately nothing the server can do here, it's responding to the REST call appropriately. On the SDK side we'll add better client-side validation for path elements ensure they're not just null, but also non-empty. For now you'll probably want to validate the userId is non-empty yourself before making the GetUser call.

HTH,
Pritesh

@priteshkp
Copy link
Member

priteshkp commented Mar 22, 2017

Whoops, didn't mean to close... keeping open to track.

@priteshkp priteshkp reopened this Mar 22, 2017
@jimmycal
Copy link
Author

Thanks for tracking this down! I have handled the empty user string on my side as you suggested.

@priteshkp
Copy link
Member

The latest version of the SDK: d1b2ef5

There's now a client side check to make sure you don't provide empty path params. I'll improve the messaging in another version, but this should at least make it less confusing by not making the wrong request to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants