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

Check .logfire for creds to respect 'if-token-present' setting #561

Merged
merged 20 commits into from
Nov 4, 2024

Conversation

sydney-runkle
Copy link
Member

@sydney-runkle sydney-runkle commented Oct 30, 2024

Fix #527

Copy link

cloudflare-workers-and-pages bot commented Oct 30, 2024

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: f8903c0
Status: ✅  Deploy successful!
Preview URL: https://7aceec80.logfire-docs.pages.dev
Branch Preview URL: https://check-creds-for-token.logfire-docs.pages.dev

View logs

logfire/_internal/config.py Outdated Show resolved Hide resolved
tests/test_configure.py Show resolved Hide resolved
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (cea397e) to head (f8903c0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #561   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          133       133           
  Lines        10238     10256   +18     
  Branches      1397      1399    +2     
=========================================
+ Hits         10238     10256   +18     

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

logfire/_internal/config.py Outdated Show resolved Hide resolved
logfire/_internal/config.py Outdated Show resolved Hide resolved
@samuelcolvin
Copy link
Member

Please can we get this merged and released, I need it for what I'm working on 🙏.

@sydney-runkle
Copy link
Member Author

Sure thing, will finish up today!

@sydney-runkle
Copy link
Member Author

sydney-runkle commented Nov 4, 2024

Still have a few follow up questions to resolve with @alexmojaki, then will push across the line.

Questions:

  1. I had to add changes to the tests to hit the /v1/info endpoint, is that ok? I think it reflects the extra token checks that are now occurring.
  2. There's one test failing bc the token isn't as expected - why is this? Is it because I'm mocking the return value from that v1/info/ call incorrectly?
  3. Before, we were skipping some of the check_token logic even when we successfully acquired a token by looking up credentials. I have us going through that logic whenever a token is available now - is that ok?

@alexmojaki
Copy link
Contributor

1 and 3 are OK, it's good to always check the token now because it may be rejected due to exceeded usage.

The test is failing because it previously only made requests using the user token fake_user_token stored in a toml file. Those requests created the project and a write token fake_token. It now checks fake_token and the tests don't expect that. You just need to tweak the assertion that's in a loop to be more specific.

@sydney-runkle
Copy link
Member Author

The test is failing because it previously only made requests using the user token fake_user_token stored in a toml file. Those requests created the project and a write token fake_token. It now checks fake_token and the tests don't expect that. You just need to tweak the assertion that's in a loop to be more specific.

Great, thanks for the feedback! Done!

Copy link
Contributor

@alexmojaki alexmojaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
@sydney-runkle
Copy link
Member Author

Thanks for the feedback :). I think I understand our auth patterns better after working in this space a bit more :)

@sydney-runkle sydney-runkle enabled auto-merge (squash) November 4, 2024 20:23
@sydney-runkle sydney-runkle merged commit aca06ab into main Nov 4, 2024
16 checks passed
@sydney-runkle sydney-runkle deleted the check-creds-for-token branch November 4, 2024 20:37
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.

if-token-present doesn't respect .logfire directory
3 participants