Skip to content

fix(cli): prevent spinner from appearing in error messages - #1434

Merged
michael-johnston merged 3 commits into
mainfrom
maj_error_formatting_fix
Sep 24, 2026
Merged

michael-johnston merged 3 commits into
mainfrom
maj_error_formatting_fix

Conversation

@michael-johnston

Copy link
Copy Markdown
Member

Before this PR CLI errors were printed while the Rich Status spinner was still live, so there were written onto the same terminal line.

For example
ado describe experiment started Status("Initializing Actuator Registry") and then looked up the experiment inside that context. For a missing experiment such as solve_mip, _ado_lookup_cli_experiment prints:

ERROR: Experiment solve_mip does not exist

via a separate Rich Console on stderr. That bypasses Live’s stdout/stderr interception. The spinner is an in-place \r line, so the error is appended to it:

⠋ Initializing Actuator RegistryERROR:  Experiment solve_mip does not exist

Fix proposed and implemented here is to initialize the actuator registry under the spinner, then stop it before lookup and error printing.

The same lookup-while-spinner-is-live pattern is also fixed in ado get experiment and ado template space --from-experiment.

Errors were printed while the Rich Status spinner was still live, so they were written onto the same terminal line.
@michael-johnston

Copy link
Copy Markdown
Member Author

This may introduce additional newlines in SUCCESS situation - checking.

@AlessandroPomponio

Copy link
Copy Markdown
Collaborator

Most of the times in these situations I believe i pass the spinner down to the function that handles the errors and i make that function stop it when needed

@michael-johnston

Copy link
Copy Markdown
Member Author

Most of the times in these situations I believe i pass the spinner down to the function that handles the errors and i make that function stop it when needed

Can you point to an instance of this pattern?

@AlessandroPomponio

Copy link
Copy Markdown
Collaborator

def format_ado_get_stats_for_operations(

@michael-johnston

Copy link
Copy Markdown
Member Author

I believe i pass the spinner down to the function that handles the errors and i make that function stop it when needed

I can't find anywhere where that function calls stop on the spinner when there is an error??

The existing pattern seems to be local to command handlers, e.g. ado/cli/resources/actuator/get.py

@michael-johnston

Copy link
Copy Markdown
Member Author

@AlessandroPomponio see above comment

@AlessandroPomponio

Copy link
Copy Markdown
Collaborator

It seems like I'm passing down the spinner/status objects to update them more than to stop them, but I think the same applies

@michael-johnston

Copy link
Copy Markdown
Member Author

So just to be clear here the error printing code in question is in _ado_lookup_cli_experiment

It's used in three of the four places the problem being addressed occurs. This doesn't take a rich status as arg.

The problem arises because the call to this function is inside a with Status: block.

The solution implemented is just to move _ado_lookup_cli_experiment out of the spinner context - because it's cheap and doesn't really need to be in spinner.

What you are proposing is to add a status parameter to _ado_lookup_cli_experiment and pass the spinner in. And update the error printing code in _ado_lookup_cli_experiment to handle stopping the spinner.

Is this correct and if so is it really necessary? Because it seems like a new pattern different to making a long running function rich Status aware (for updates) - instead making a short running function status aware in to handle error printing if it happens to be in a rich context.

Comment thread tests/ado/describe/test_ado_describe.py
Comment thread ado/cli/resources/experiment/describe.py Outdated
michael-johnston and others added 2 commits September 24, 2026 09:37
Co-authored-by: Alessandro Pomponio <10339005+AlessandroPomponio@users.noreply.github.com>
Signed-off-by: Michael Johnston <66301584+michael-johnston@users.noreply.github.com>
@AlessandroPomponio AlessandroPomponio changed the title fix: formatting on error in CLI output fix(cli): prevent spinner from appearing in error messages Sep 24, 2026
@michael-johnston
michael-johnston added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit 339d12b Sep 24, 2026
18 checks passed
@michael-johnston
michael-johnston deleted the maj_error_formatting_fix branch September 24, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants