Skip to content

Conversation

@gmazoyer
Copy link
Contributor

@gmazoyer gmazoyer commented Sep 3, 2025

This change fixes the behaviour of the infrahubctl info command when no username/password or API token are provided. Since the GraphQL queries are run as anonymous, in this case, we have to skip fetching user details.

Summary by CodeRabbit

  • Bug Fixes

    • infrahubctl info now works when run without authentication.
    • Detailed output shows “User: anonymous” when no credentials are provided.
    • User and group details are shown only when authenticated (username or API token).
    • Minor wording correction in the Infrahub information panel.
  • Tests

    • Added tests for authenticated info and detailed outputs.
    • Added test to validate anonymous detailed output, including presence of “anonymous” and key sections.

@coderabbitai
Copy link

coderabbitai bot commented Sep 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

  • Added changelog entry documenting fix for running infrahubctl info as an anonymous user.
  • Simplified InfrahubClient.get_user (async and sync) to directly return execute_graphql results; no signature changes.
  • Updated CLI info command to initialize the client once and conditionally fetch user details based on presence of username or API token.
  • Detailed output now shows “User: anonymous” when no credentials are provided; otherwise shows user and groups.
  • Kept version retrieval via client.get_version after pre-initialization.
  • Adjusted tests to pass API token for authenticated paths and added a test for anonymous detailed info output.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 320f919 and 88656ef.

📒 Files selected for processing (4)
  • changelog/398.fixed.md (1 hunks)
  • infrahub_sdk/client.py (2 hunks)
  • infrahub_sdk/ctl/cli_commands.py (3 hunks)
  • tests/unit/ctl/test_cli.py (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gma-20250903-ihs134

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 3, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88656ef
Status: ✅  Deploy successful!
Preview URL: https://840f2a41.infrahub-sdk-python.pages.dev
Branch Preview URL: https://gma-20250903-ihs134.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##           stable     #524      +/-   ##
==========================================
+ Coverage   75.74%   75.78%   +0.04%     
==========================================
  Files         100      100              
  Lines        8846     8859      +13     
  Branches     1732     1738       +6     
==========================================
+ Hits         6700     6714      +14     
+ Misses       1670     1669       -1     
  Partials      476      476              
Flag Coverage Δ
integration-tests 34.74% <0.00%> (+0.07%) ⬆️
python-3.10 48.27% <100.00%> (+0.06%) ⬆️
python-3.11 48.27% <100.00%> (+0.08%) ⬆️
python-3.12 48.25% <100.00%> (+0.06%) ⬆️
python-3.13 48.27% <100.00%> (+0.08%) ⬆️
python-3.9 46.95% <100.00%> (+0.06%) ⬆️
python-filler-3.12 25.05% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/client.py 69.64% <100.00%> (+0.15%) ⬆️
infrahub_sdk/ctl/cli_commands.py 69.51% <100.00%> (+0.37%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmazoyer gmazoyer requested a review from a team September 3, 2025 11:20
@gmazoyer gmazoyer marked this pull request as ready for review September 3, 2025 11:58
@gmazoyer gmazoyer merged commit 266fecc into stable Sep 3, 2025
19 of 20 checks passed
@gmazoyer gmazoyer deleted the gma-20250903-ihs134 branch September 3, 2025 11:58
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.

bug: infrahubctl info returns a GraphQL error when user is not authenticated

2 participants