[CLI] Space hot-reload: wait for up-to-date infos#4049
[CLI] Space hot-reload: wait for up-to-date infos#4049
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| typer.secho("Waiting for up-to-date Space infos", fg=typer.colors.BRIGHT_BLACK) | ||
| time.sleep(2) | ||
| if space_info.sha != commit_sha: | ||
| raise CLIError(f"Expected SHA {commit_sha} after hot-reload but got {space_info.sha}") |
There was a problem hiding this comment.
SHA check crashes when skip_checks is True
Medium Severity
When skip_checks=True, current_sha is None, so the while-loop condition space_info.sha == None is almost always False and the polling loop is never entered. The code then falls through to space_info.sha != commit_sha, which will likely fail because the webhook hasn't processed yet — the exact lag scenario this PR is meant to handle. This is a regression: before this change, --skip-checks users could still see the summary; now they get a CLIError.
Additional Locations (1)
| if current_sha is None: | ||
| break | ||
| typer.secho("Waiting for up-to-date Space infos", fg=typer.colors.BRIGHT_BLACK) | ||
| time.sleep(2) |
There was a problem hiding this comment.
Polling loop lacks timeout, may hang indefinitely
Low Severity
The while loop polling for updated Space info has no timeout or maximum retry count. If the backend never updates the SHA (e.g., server error, stuck webhook), the CLI will hang indefinitely making API calls every 2 seconds with no way to exit besides Ctrl+C and no feedback about progress or elapsed time.
| while (space_info := api.space_info(space_id)).sha == current_sha: | ||
| if current_sha is None: | ||
| break | ||
| typer.secho("Waiting for up-to-date Space infos", fg=typer.colors.BRIGHT_BLACK) | ||
| time.sleep(2) |
There was a problem hiding this comment.
this should use StatusLine which overwrites the same line on stderr instead of printing a new line every 2 sec
| while (space_info := api.space_info(space_id)).sha == current_sha: | |
| if current_sha is None: | |
| break | |
| typer.secho("Waiting for up-to-date Space infos", fg=typer.colors.BRIGHT_BLACK) | |
| time.sleep(2) | |
| status = StatusLine() | |
| while (space_info := api.space_info(space_id)).sha == current_sha: | |
| if current_sha is None: | |
| break | |
| status.update("Waiting for up-to-date Space info...") | |
| time.sleep(2) |


Space backend webhook handler is sometimes lagging, let's make hot-reload still work
Note
Medium Risk
Changes the Spaces hot-reload flow by pinning uploads to the current running SHA and polling
space_infountil it reflects the new commit, which could impact CLI behavior (including potential waits) if the backend is slow or inconsistent.Overview
Improves
hf spaces hot-reloadrobustness when Space metadata lags by capturing the current running SHA and using it asparent_commitfor the upload.After triggering the hot-reload, the CLI now polls
api.space_infountil the SHA changes and then validates that the reported SHA matches the newly created commit, failing fast with a clear error if the expected commit isn’t reflected yet.Written by Cursor Bugbot for commit dd2c0ea. This will update automatically on new commits. Configure here.