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

Merged
MA
3mo ago
+5-7

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

reflex-dev/reflex#6918 (reflex cloud whoami / reflex cloud token, merged as dfb4ef0db13edd5f8291a33556f5339ccef57390) was branched before reflex-dev/reflex#6939 and reflex-dev/reflex#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 reflex-dev/reflex#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 reflex-dev/reflex#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 reflex-dev/reflex#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: reflex-dev/reflex#6918 and reflex-dev/reflex#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