Skip to content

Clarify CLI account switching and logout scope - #2552

Merged
alexmojaki merged 3 commits into
mainfrom
fix/cli-account-guidance-2462-reviewed
Oct 13, 2026
Merged

alexmojaki merged 3 commits into
mainfrom
fix/cli-account-guidance-2462-reviewed

Conversation

@alexmojaki

Copy link
Copy Markdown
Contributor

Copy of #2546

@alexmojaki
alexmojaki enabled auto-merge (squash) October 13, 2026 14:03

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 issues found across 4 files

Confidence score: 3/5

  • In logfire-sdk/logfire/_internal/cli/auth.py, the no-target logout suggestion includes --base-url <base-url>, which the shell treats as input redirection rather than an option value. Omit the target option so logout clears all tokens.
  • In tests/test_cli.py, the nested-help assertion expects --region and --base-url, but those options are only registered on the top-level parser, so the test fails. Check top-level help separately or expose the options in nested help.
  • In tests/test_cli.py, this case fails when LOGFIRE_BASE_URL is set because auth prints that URL instead of <base-url>. Clear or explicitly set the variable for the test.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/test_cli.py">

<violation number="1" location="tests/test_cli.py:1407">
P2: This case fails whenever the test process has `LOGFIRE_BASE_URL` set: `auth` uses that URL and prints it instead of `<base-url>`. Clear or explicitly set the variable for this test case.</violation>

<violation number="2" location="tests/test_cli.py:1452">
P2: These nested help outputs do not include `--region` or `--base-url`; both options are registered only on the top-level parser, so this assertion makes the test fail. Check the top-level help separately or expose the options on these subparsers.</violation>
</file>

<file name="logfire-sdk/logfire/_internal/cli/auth.py">

<violation number="1" location="logfire-sdk/logfire/_internal/cli/auth.py:43">
P2: With no target selected, the suggested commands contain `--base-url <base-url>`, which the shell parses as input redirection rather than an option value. Omit the target option in this case so logout clears all tokens and auth can prompt for a region.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/test_cli.py
[
(['--region', 'us', 'auth'], '--base-url https://logfire-us.pydantic.dev'),
(['--base-url', 'https://logfire-us.pydantic.dev', 'auth'], '--base-url https://logfire-us.pydantic.dev'),
(['auth'], '--base-url <base-url>'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This case fails whenever the test process has LOGFIRE_BASE_URL set: auth uses that URL and prints it instead of <base-url>. Clear or explicitly set the variable for this test case.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/test_cli.py, line 1407:

<comment>This case fails whenever the test process has `LOGFIRE_BASE_URL` set: `auth` uses that URL and prints it instead of `<base-url>`. Clear or explicitly set the variable for this test case.</comment>

<file context>
@@ -1399,13 +1399,81 @@ def test_auth_permanent_failure(tmp_path: Path) -> None:
+    [
+        (['--region', 'us', 'auth'], '--base-url https://logfire-us.pydantic.dev'),
+        (['--base-url', 'https://logfire-us.pydantic.dev', 'auth'], '--base-url https://logfire-us.pydantic.dev'),
+        (['auth'], '--base-url <base-url>'),
+    ],
+)
</file context>

Comment thread tests/test_cli.py

assert exc_info.value.code == 0
output = ' '.join(capsys.readouterr().out.split())
assert '--region' in output

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: These nested help outputs do not include --region or --base-url; both options are registered only on the top-level parser, so this assertion makes the test fail. Check the top-level help separately or expose the options on these subparsers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/test_cli.py, line 1452:

<comment>These nested help outputs do not include `--region` or `--base-url`; both options are registered only on the top-level parser, so this assertion makes the test fail. Check the top-level help separately or expose the options on these subparsers.</comment>

<file context>
@@ -1399,13 +1399,81 @@ def test_auth_permanent_failure(tmp_path: Path) -> None:
+
+    assert exc_info.value.code == 0
+    output = ' '.join(capsys.readouterr().out.split())
+    assert '--region' in output
+    assert '--base-url' in output
+    assert 'LOGFIRE_BASE_URL' in output
</file context>

logged_in = tokens_collection.is_logged_in(logfire_url)

if logged_in:
target = f'--base-url {logfire_url or "<base-url>"}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: With no target selected, the suggested commands contain --base-url <base-url>, which the shell parses as input redirection rather than an option value. Omit the target option in this case so logout clears all tokens and auth can prompt for a region.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At logfire-sdk/logfire/_internal/cli/auth.py, line 43:

<comment>With no target selected, the suggested commands contain `--base-url <base-url>`, which the shell parses as input redirection rather than an option value. Omit the target option in this case so logout clears all tokens and auth can prompt for a region.</comment>

<file context>
@@ -40,11 +40,13 @@ def parse_auth(args: argparse.Namespace) -> None:
     logged_in = tokens_collection.is_logged_in(logfire_url)
 
     if logged_in:
+        target = f'--base-url {logfire_url or "<base-url>"}'
         sys.stderr.writelines(
             (
</file context>
Suggested change
target = f'--base-url {logfire_url or "<base-url>"}'
target = f'--base-url {logfire_url}' if logfire_url else ''

@alexmojaki
alexmojaki merged commit 2c1a5e3 into main Oct 13, 2026
31 checks passed
@alexmojaki
alexmojaki deleted the fix/cli-account-guidance-2462-reviewed branch October 13, 2026 14:08
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  logfire-sdk/logfire/_internal/cli
  __init__.py
  auth.py
Project Total  

This report was generated by python-coverage-comment-action

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.

2 participants