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

Resolve login when repr-ing AuthenticatedUser #2945

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xmo-odoo
Copy link
Contributor

@xmo-odoo xmo-odoo commented Apr 8, 2024

It's extremely confusing to dump an AuthenticatedUser and get AuthenticatedUser(login=None) even though the AuthenticatedUser is correctly set up, and necessarily has a login.

This risks incurring additional requests, but I think in the contexts where it would be used (mostly at the shell or when debugging services) it's more helpful to actually show the information.

It's extremely confusing to dump an `AuthenticatedUser` and get `AuthenticatedUser(login=None)` even though the `AuthenticatedUser` is correctly set up, and necessarily has a login.

This risks incurring additional requests, but I think in the contexts where it would be used (mostly at the shell or when debugging services) it's more helpful to actually show the information.
@EnricoMi
Copy link
Collaborator

I understand the confusion. But this project favours no unwanted REST calls. This change would cause a request for everyone else using this project, and there would be no way to not have the REST call in this situation.

I think you can easily call update() before printing the user or print user.login to get the desired behaviour.

@xmo-odoo
Copy link
Contributor Author

Then maybe the repr for AuthenticatedUser when no call has been made say something like unknown / unresolved login?

Obviously it's easy to trigger the resolution when you know that's what the issue is, but when you don't and you assume the repr is the actual thing you start trying to debug why your user does not have a login and where that got lost.

@EnricoMi
Copy link
Collaborator

I like the UNKNOWN representation when login is not set.

@xmo-odoo
Copy link
Contributor Author

I like the UNKNOWN representation when login is not set.

Re-set to the old code but added a fallback to <UNKNOWN> as placeholder.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.73%. Comparing base (7266e81) to head (321642e).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2945      +/-   ##
==========================================
- Coverage   96.74%   96.73%   -0.02%     
==========================================
  Files         147      147              
  Lines       14978    14984       +6     
==========================================
+ Hits        14491    14495       +4     
- Misses        487      489       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

None yet

3 participants