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

Switching client ids causes auth errors due to token caching #58

Open
sswatson opened this issue Oct 9, 2022 · 1 comment
Open

Switching client ids causes auth errors due to token caching #58

sswatson opened this issue Oct 9, 2022 · 1 comment
Labels
priority:medium type:bug Something isn't working

Comments

@sswatson
Copy link

sswatson commented Oct 9, 2022

Repro steps:

  1. Create a profile named my-profile in ~/.rai/config.
  2. Run a transaction with that profile. For example, create a client object and do client.listDatabases.
  3. Change the client id and secret in ~/.rai/config to credentials associated with a different account.
  4. Run client.listDatabases again.

Behavior

Expected behavior: get a list of databases from the new account.
Actual behavior: get a list of databases from the old account.

Diagnosis

It took me a very long time to figure this out, but I'm pretty sure it's because of readTokenCache.

Discussion

This hidden state makes debugging very difficult for people building applications, because you console log the credentials picked up by readConfig and see that they are correct, but then there's a mismatch with what you're getting back from the server. Since the server doesn't get information about the profile name, you know the caching isn't happening on that side.

Furthermore, I think this is likely to be a common scenario, because it comes up any time someone changes their mind about which credentials should be associated with a particular profile name. This might be because of a mistake, or because you want to change default to work around a lack of profile-specific behavior in the application that's using the SDK.

Proposed fix

The token cache could be keyed by profile name and client_id rather than just profile name. See Draft PR #59 for the idea.

@sswatson sswatson added type:bug Something isn't working priority:medium labels Oct 9, 2022
@sswatson sswatson changed the title Profile caching Switching client ids causes auth errors due to token caching Oct 9, 2022
@billscheidel-rai
Copy link

Note: This issue has been migrated to https://relationalai.atlassian.net/browse/RAI-7257.

This link is only accessible to employees of RelationalAI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:medium type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants