Bug - Fix CLI login error#231
Bug - Fix CLI login error#231miguel-figueiredoPT wants to merge 8 commits intoOpenIntegrationEngine:mainfrom
Conversation
20f5769 to
599ec0c
Compare
mgaffigan
left a comment
There was a problem hiding this comment.
Omit the null check or handle at :192. Other comment is just a suggestion.
71cc19c to
8e7a76a
Compare
NicoPiel
left a comment
There was a problem hiding this comment.
Looks good. Mitch already suggested the only change I would have made.
tonygermano
left a comment
There was a problem hiding this comment.
I was just testing, and this does resolve the uncaught exception, but the program still hangs after a failed login. We're going to need to dig a little more to see why the program is still not ending.
Looking at the error messages, I think the first one on line 191 is fine, because I can't think of a reason that we'd ever get a UnauthorizedException where the response wasn't a LoginStatus, so printing the stack trace would be useful there.
The second one on line 197 we might want to make a little more user-friendly, since that is the one that shows up for a bad password. I don't know that it's necessary to print the loginStatus, since we already know we have one, and it's not successful at this point. Perhaps a message like, Could not login to server. Please check your username and password and try again. would be more appropriate. This is similar to what was requested in the linked issue.
tonygermano
left a comment
There was a problem hiding this comment.
It was hanging because the client wasn't getting closed after the function returned, but I think it's better to return an appropriate exit code than to let it return 0 like it worked successfully since this can be used to run scripts as well as interactively.
| error("Could not login to server. Status: " + loginStatus.getStatus(), null); | ||
| return; |
There was a problem hiding this comment.
| error("Could not login to server. Status: " + loginStatus.getStatus(), null); | |
| return; | |
| error("Could not login to server. Please check your username and password and try again.", null); | |
| System.exit(77); |
77 is the unix exit code for EX_NOPERM. This code is already using exit code 2 for usage errors.
There was a problem hiding this comment.
Exit codes added:
77 - Derived from UnauthorizedException with a login status
70 - Null login status (should happen in exceptions other than Unauthorized)
There was a problem hiding this comment.
@tonygermano should we follow the same exit code structure when returning from the runScript/runConsole?
Exceptions on those functions are currently being ignored and the command just continues.
There was a problem hiding this comment.
Do you mean in those catch blocks at the end of runShell between lines 218 and 224? I think that would be a good idea if you want to add them.
There was a problem hiding this comment.
Pull request overview
This PR fixes a CLI login error handling issue by catching UnauthorizedException and extracting the LoginStatus from the exception's response. The fix addresses issue #224 where login failures were not properly handled.
Key Changes:
- Added exception handling around
client.login()to catchUnauthorizedException - Extracted
LoginStatusfrom the exception response using pattern matching - Improved error messaging to include the login status details
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
Signed-off-by: miguelfigueiredo <miguelsfigueiredo90@gmail.com>
db45250 to
10e6da1
Compare
This PR implements a change on the CLI - When logging in, catch UnauthorizedException and fetch the login status from it.
Resolution for issue: #224