Repository navigation
Clarify CLI account switching and logout scope - #2552
Conversation
There was a problem hiding this comment.
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--regionand--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 whenLOGFIRE_BASE_URLis set becauseauthprints 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
| [ | ||
| (['--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>'), |
There was a problem hiding this comment.
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>
|
|
||
| assert exc_info.value.code == 0 | ||
| output = ' '.join(capsys.readouterr().out.split()) | ||
| assert '--region' in output |
There was a problem hiding this comment.
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>"}' |
There was a problem hiding this comment.
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>
| target = f'--base-url {logfire_url or "<base-url>"}' | |
| target = f'--base-url {logfire_url}' if logfire_url else '' |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
Copy of #2546