Skip to content

fix(hosting-cli): repair main after the whoami/token merge - #6954

Merged
masenf merged 1 commit into
mainfrom
claude/precommit-unit-test-errors-n0ccsg
Aug 27, 2026
Merged

fix(hosting-cli): repair main after the whoami/token merge#6954
masenf merged 1 commit into
mainfrom
claude/precommit-unit-test-errors-n0ccsg

Conversation

@masenf

@masenf masenf commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

What happened

#6918 (reflex cloud whoami / reflex cloud token, merged as dfb4ef0) was branched before #6939 and #6893 landed. Nothing conflicted textually, so it merged cleanly and broke main on two fronts:

1. Unit tests — test_cli_imports_without_reflex_base[reflex_cli.v2.deployments]

reflex_cli/v2/auth.py imports reflex_base.utils.log at module scope, but #6939 made reflex-base optional precisely because it does not exist on the reflex versions the hosting CLI advertises support for (MINIMUM_REFLEX_VERSION predates the workspace split). reflex_cli/v2/deployments.py imports auth unconditionally, so on reflex older than 0.9 importing any hosting CLI command raised ImportError: No module named 'reflex_base':

packages/reflex-hosting-cli/src/reflex_cli/v2/deployments.py:16: in <module>
    from reflex_cli.v2.auth import token_command, whoami_command
packages/reflex-hosting-cli/src/reflex_cli/v2/auth.py:12: in <module>
    from reflex_base.utils import log
E   ImportError: No module named 'reflex_base'

2. Pre-commit — 22 pyright errors in tests/units/reflex_cli/v2/test_auth.py

The test resolved the CLI with an inline get_command(hosting_cli) if isinstance(hosting_cli, Typer) else hosting_cli, which types as Group | Command. Since the typer upgrade in #6893 vendored click, that is not assignable to click.Command, so every one of the 22 runner.invoke(hosting_cli, ...) calls failed the pyright hook:

error: Argument of type "Group | Command" cannot be assigned to parameter "cli" of type "Command" in function "invoke"
    "typer._click.core.Command" is not assignable to "click.core.Command" (reportArgumentType)

The fix

  • auth.py resolves log through reflex_cli.utils.log — the shim every other CLI module already uses, which re-exports reflex-base's SUCCESS when it is importable and defines its own otherwise. On reflex 0.9 and up this is the identical object, so there is no behavior change.
  • reflex_cli.v2.auth is added to test_cli_imports_without_reflex_base's module list, so the guard names the module directly instead of only catching it transitively through deployments. It fails without the auth.py change.
  • test_auth.py uses as_click_command, the helper Upgrade dev tooling and fix docstring style #6893 added for exactly this and which the sibling CLI tests already use, instead of casting inline.

Verification

Both failures reproduce on 9f7f82c5 (current main) and are gone here:

  • uv run pytest tests/units/reflex_cli — 444 passed (was 1 failed)
  • uv run pytest tests/units — 7766 passed, 18 skipped. The only remaining failures, test_processes.py::test_is_process_on_port_free_port and ::test_is_process_on_port_concurrent_access, are pre-existing and environmental (this sandbox has no IPv6: Address family not supported by protocol); they fail identically on main at dfb4ef0d^.
  • uv run pre-commit run --all-files — all hooks pass (ruff-format, ruff-check, codespell, update-pyi-files, pyright, ty, biome)

No news fragment: #6918 and #6939 are both unreleased (latest tag is reflex-hosting-cli-v0.1.70, before either merged), so the broken import never shipped and there is nothing user-facing to describe. Please apply skip-changelog.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QNTSjh5JBcVFfTx7Jvn3DT


Generated by Claude Code

Review in cubic

#6918 was branched before #6939 and #6893 landed, so merging it left main
failing both pre-commit and the unit tests.

- `reflex_cli.v2.auth` imported `reflex_base.utils.log` at module scope.
  #6939 made reflex-base optional, because it does not exist on the reflex
  versions the CLI advertises support for, and `reflex_cli.v2.deployments`
  imports auth unconditionally — so importing any hosting CLI command
  raised ImportError on reflex older than 0.9, failing
  `test_cli_imports_without_reflex_base[reflex_cli.v2.deployments]`. It now
  resolves `log` through `reflex_cli.utils.log`, the shim the rest of the
  CLI uses, which falls back to its own SUCCESS level when reflex-base is
  absent. `reflex_cli.v2.auth` joins that test's module list so the guard
  names the module directly instead of catching it only through
  deployments.

- `tests/units/reflex_cli/v2/test_auth.py` resolved the CLI with an inline
  `get_command(...) if isinstance(hosting_cli, Typer)`, which types as
  `Group | Command`; since the typer upgrade in #6893 vendored click, that
  is not assignable to `click.Command`, so every `runner.invoke` call was a
  pyright error (22 in total). It now uses the `as_click_command` helper
  #6893 added for exactly this, which casts once.

No behavior change: on reflex 0.9 and up `reflex_cli.utils.log.SUCCESS` is
the same object the module imported before.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNTSjh5JBcVFfTx7Jvn3DT
@masenf
masenf requested a review from a team as a code owner August 27, 2026 17:25
@masenf masenf added the skip-changelog For doc/internal changes label Aug 27, 2026

@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.

No issues found across 3 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing claude/precommit-unit-test-errors-n0ccsg (95328cb) with main (9f7f82c)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores compatibility for hosting CLI authentication commands when reflex-base is unavailable and updates authentication tests for the vendored Click/Typer command types.

  • Routes authentication logging through the hosting CLI’s compatibility shim.
  • Adds direct import coverage for reflex_cli.v2.auth without reflex-base.
  • Reuses the shared as_click_command test helper for authentication command invocations.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security issues identified.

The logging shim supplies the interface used by the authentication commands in both supported dependency configurations, and the shared command-conversion helper preserves the prior runtime conversion while resolving the type-checking failure.

Important Files Changed

Filename Overview
packages/reflex-hosting-cli/src/reflex_cli/v2/auth.py Replaces the optional reflex_base logging import with the CLI shim, which preserves the logging interface used by authentication commands.
tests/units/reflex_cli/utils/test_log.py Extends the optional-dependency import test to cover the authentication module directly.
tests/units/reflex_cli/v2/test_auth.py Replaces an inline Typer conversion with the established typed helper without changing the tested command surface.

Reviews (1): Last reviewed commit: "fix(hosting-cli): repair main after the ..." | Re-trigger Greptile

@masenf
masenf merged commit ceff479 into main Aug 27, 2026
110 of 111 checks passed
@masenf
masenf deleted the claude/precommit-unit-test-errors-n0ccsg branch August 27, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog For doc/internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants