Skip to content

fix(hosting-cli): fail cloud config when PyYAML is missing - #7670

Open
gaurav0107 wants to merge 1 commit into
reflex-dev:mainfrom
gaurav0107:fix/7092-cloud-config-json-missing-pyyaml
Open

gaurav0107 wants to merge 1 commit into
reflex-dev:mainfrom
gaurav0107:fix/7092-cloud-config-json-missing-pyyaml

Conversation

@gaurav0107

Copy link
Copy Markdown
Contributor

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)

Description

Closes #7092.

On main, regions and vmtypes already exit 1 and write no JSON document when the request fails (#6917 / #7207). The case from the issue that is still open is reflex cloud config --json without PyYAML. hosting.generate_config logged "Please install PyYAML to use this command" and returned None. That is the same value it returns when a cloud.yml already exists, so the command printed {"generated": false, "path": null} and exited 0.

This PR makes generate_config raise click.exceptions.Exit(1) after logging that error. The command now exits 1, and with --json it writes nothing to stdout, which is how regions/vmtypes handle a failed read. The check still runs before authentication, so no token is requested.

I left the existing-cloud.yml case alone. It still returns None and exits 0 with generated: false, as test_generate_cloud_config_json_output_when_nothing_written requires.

One behaviour change: plain reflex cloud config (without --json) also exits 1 now when PyYAML is missing, where it used to exit 0. The news fragment mentions this.

News fragment: packages/reflex-hosting-cli/news/+config-missing-pyyaml.bugfix.md.

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?

Validation

Tests (each one makes PyYAML unimportable with mocker.patch.dict("sys.modules", {"yaml": None})):

  • tests/units/reflex_cli/v2/test_vmtypes_regions.py
    • test_generate_cloud_config_json_without_pyyaml_writes_no_document: exit 1, empty stdout, no auth call.
    • test_generate_cloud_config_without_pyyaml_exits_nonzero: exit 1, the PyYAML error is logged at ERROR, nothing printed.
  • tests/units/reflex_cli/utils/test_hosting.py
    • test_generate_config_without_pyyaml_raises: Exit(1), no auth call.
    • test_generate_config_with_existing_file_returns_none: an existing cloud.yml is left unchanged and None is returned.

On main, the three PyYAML tests fail (the command exits 0 and generate_config does not raise). With this change, uv run pytest tests/units/reflex_cli passes (804 tests). ruff check, ruff format --check, and pre-commit (pyright, ty, codespell) pass on the changed files. I did not run the full tests/units suite locally; CI will.


🤖 Opened with Superhuman, an open-source contribution agent.

`generate_config` logged "Please install PyYAML" and returned None, the
same value it returns when a cloud.yml already exists. `reflex cloud
config --json` therefore printed {"generated": false, "path": null} and
exited 0, so a caller trusting the exit code read a missing dependency
as "nothing to do".

Raise `click.exceptions.Exit(1)` instead, so the command exits non-zero
and, with --json, writes no document -- the same contract the regions
and vmtypes commands follow for a failed read. The existing-file case
keeps returning None and exiting 0.
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with no actionable issues found.

Summary

reflex cloud config now exits with status 1 when PyYAML is missing, instead of reporting success.

  • Cloud config reports missing PyYAML as a command failure.

Review checks were limited to reading code; tests were not run.

Reviews (1) · Last reviewed commit: "fix(hosting-cli): fail cloud config when..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.13%

2 warnings

⚠️ 17 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 147 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_set_state[redis] 34.9 ms 33.5 ms +4.13%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaurav0107:fix/7092-cloud-config-json-missing-pyyaml (7c688cd) with main (9c64f1e)

Open in CodSpeed

@gaurav0107
gaurav0107 marked this pull request as ready for review October 27, 2026 12:37
@gaurav0107
gaurav0107 requested a review from a team as a code owner October 27, 2026 12:37

@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 4 files

View guided diff | Re-trigger cubic

@masenf masenf added the bug Something isn't working label Oct 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloud JSON commands report success and empty results after authentication or dependency failures

2 participants