Skip to content

studio: report why launcher recovery failed, not that it was absent - #9924

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
Sletch:fix/9804-report-why-launcher-recovery-failed
Oct 5, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
Sletch:fix/9804-report-why-launcher-recovery-failed

Conversation

@Sletch

@Sletch Sletch commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Refs #9804.

The defect

validate_launcher() samples _launcher_health_error() before attempting recovery and
reports that value, while _restore_runnable() returns a bare bool — so the verdict
recovery actually acted on is computed and then discarded.

error = self._launcher_health_error()      # _LAUNCHER_ABSENT
restored = self._restore_runnable()        # False -- and WHY is thrown away
if published or not restored:
    typer.echo(f"Error: Unsloth Studio update failed because {error}.", err = True)

Once the launcher is gone, error is _LAUNCHER_ABSENT whatever the cause. So a failure
decided by the interpreter probe is reported as absence — the one condition
_recovered_cli_health_error exists to excuse (#8592).

Reproduced at head

Using the file's own fixtures — launcher quarantined away, managed CLI answering
returncode = 3:

what _recovered_cli_health_error() returned the managed Python CLI returned 3 for --version
what the user was shown ...because the updated launcher is not on disk

This is why #9804 cannot be diagnosed from its own log. That report shows not on disk
together with Manual recovery copy retained at:. The second line only prints when
restored is false, so recovery's own check failed as well, on an install whose Studio then
started normally, and nothing says what failed. With a backup on disk, as that line shows, the
check is the restored launcher's own --version; the interpreter is asked only if no restored
copy is left on disk or the copy is blocked by policy. An earlier version of this description
said the interpreter probe failed; the log does not show which check did.

The report also prints that line once. validate_launcher raises inside the with block and
__exit__ runs recovery again, so a failure that persists with the backup intact prints it
twice. Replayed with this file's fixtures, a persistent failure prints it twice, and one that
clears before __exit__ prints it once. So by then, either recovery succeeded or the backup was
no longer usable. That fits a transient failure, which is not confirmed.

The change

_restore_failure_reason() is the same walk returning the reason; _restore_runnable() is
now the bool of it, so __exit__ is unchanged.

validate_launcher reports that reason only when the sampled error is _LAUNCHER_ABSENT, the
one value that cannot name a cause. Any other sampled error is the failure of the launcher setup
published, and it stays whether or not recovery succeeded, since by then the reason describes the
copy put back in its place. That second half is oobabooga's feb3885a2: Codex found that the
first version, reason or error, reported the restored copy's failure over the published
launcher's.

_recover_missing_launcher already reports its cause this way, so this is the exit-time
half of a convention the entry-time half already keeps.

Tests

tests/python/test_windows_studio_update_launcher.py, 4 added:

test pins fails without the change
test_a_failed_recovery_reports_the_verdict_it_acted_on the interpreter's verdict reaches the user yes
test_a_failed_recovery_with_no_interpreter_says_both the no-interpreter wording, which had no test and is only reachable through _recovered_cli_health_error yes
test_a_recovered_launcher_still_reports_what_setup_published parity guard for the case the reason must not speak in no — by design
test_a_published_launcher_keeps_its_own_verdict_when_recovery_also_fails a published launcher's own verdict survives a failed recovery no — it fails under the first version, reason or error

Re-measured 2026-09-16 with this branch merged into main at 1066d16af. The file passes 66 on
Windows and 62 on Linux, where 4 Windows-only tests skip. With main's studio.py under these
tests, exactly the two marked yes fail, printing "the updated launcher is not on disk".

With unsloth_cli/tests added, nothing that passes on main fails here. Linux fails the same 4
tests by name on both sides, with 1,531 passes against 1,527. Windows fails 66 here against
main's 67, all of them shared; the one extra on main, test_update_verifies_by_default,
passes on both when its file runs alone.

An earlier version of this description predated feb3885a2 and the rebase onto c8ed02f69. It
said 3 tests and reason or error, and gave counts from the old base.

One consequence worth naming

The message for a failed recovery now varies with what recovery found, where it was
previously fixed. Nothing asserted the old text, but a downstream log scraper matching the
literal absence string would stop matching.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main still prints the pre-recovery error at unsloth_cli/commands/studio.py:4654, so a failed interpreter probe is reported as "not on disk" as in #9804, and returning the reason from the same walk keeps exit unchanged. Will get this reviewed.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sletch and others added 2 commits September 14, 2026 12:19
`validate_launcher` sampled `_launcher_health_error()` before attempting
recovery and then printed that, while `_restore_runnable()` returned a bare
bool -- so the verdict recovery actually acted on was computed and discarded.

Reproduced at head with the file's own fixtures: launcher quarantined away,
managed CLI answering `returncode = 3`. `_recovered_cli_health_error()`
returns "the managed Python CLI returned 3 for --version", and the user is
told:

    Error: Unsloth Studio update failed because the updated launcher is not on disk.

Once the launcher is gone `_launcher_health_error()` answers `_LAUNCHER_ABSENT`
whatever the cause, so that message named the one condition
`_recovered_cli_health_error` exists to excuse (unslothai#8592) and said nothing about
the update. It is why unslothai#9804 cannot be diagnosed from its own log: the report
shows "not on disk" and "Manual recovery copy retained at", which together mean
the interpreter probe failed too -- on an install whose Studio then started
normally -- and nothing says why.

`_restore_failure_reason()` is the same walk returning the reason;
`_restore_runnable()` is now the bool of it, so `__exit__` is unchanged.
`validate_launcher` reports `reason or error`: the sampled error still answers
when recovery SUCCEEDED and the launcher setup published is itself the broken
one, which is what the `published` arm is for.

`_recover_missing_launcher` already reports its cause this way, so this is the
exit-time half of a convention the entry-time half already keeps.

Regression tests `test_a_failed_recovery_reports_the_verdict_it_acted_on` and
`test_a_failed_recovery_with_no_interpreter_says_both` pin both reasons the
interpreter fallback can give; both fail on the unfixed code. The second also
covers `_interpreter_health_error`'s "is missing" wording, which had no test
and is only reachable through `_recovered_cli_health_error`.
`test_a_recovered_launcher_still_reports_what_setup_published` is the parity
guard for the case the reason must not speak in.

One consequence worth naming: the message for a failed recovery now varies with
what the interpreter said, where it was previously fixed. Nothing asserted the
old text, but a downstream log scraper matching the literal absence string
would stop matching.

Refs unslothai#9804.
@Sletch
Sletch force-pushed the fix/9804-report-why-launcher-recovery-failed branch from 4e48c9d to feb3885 Compare September 14, 2026 10:27
@danielhanchen danielhanchen self-assigned this Oct 5, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

Review record for #9924, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#433.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 6dc5e1b203 (this PR's ccf1dfa31)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6dc5e1b203

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 6dc5e1b203 (this PR's ccf1dfa31).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants