fix(BA-5559): handle non-dict data field in login response#10732
Open
fix(BA-5559): handle non-dict data field in login response#10732
Conversation
The login CLI assumed the server always returns a dict in the response data field. When an active session exists, the server returns a plain string, causing an AttributeError on .get(). Add isinstance checks to handle both string and dict responses.
478b11d to
30f5986
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the v2 CLI login flow when the server returns a non-dict data field (e.g., a plain string message), by safely extracting an error detail string before calling .get().
Changes:
- Add
isinstance(..., dict)guards when readingdata["data"]["details"]during login failure handling. - Improve resilience of OTP prompting logic by handling non-dict
datapayloads without raisingAttributeError.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fregataa
requested changes
Apr 2, 2026
Member
|
Please check lint and typecheck failure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves BA-5559
Summary
AttributeErrorinlogin_cmd.pywhen the server returns a string in thedatafield instead of a dictisinstancechecks before calling.get()on the response data fielddatais a plain stringTest plan
./bai loginwhen an active session exists — should show a clear error message instead of crashing./bai login --force— should override existing session successfully