Skip to content

Fix two pre-existing Backend CI failures blocking every open PR - #7639

Merged
danielhanchen merged 2 commits into
mainfrom
fix-model-picker-contracts-encoding
Jul 30, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix-model-picker-contracts-encoding

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Repo tests (CPU) is currently red on main:

FAILED tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding
AssertionError: 1 file reads in the test trees touch a checked-in file with the
platform default encoding, so they break on Windows as soon as that file gains a
non-ASCII byte. Pass encoding = "utf-8":
["tests/studio/test_model_picker_contracts.py:32: read_text()"]

_read_backend arrived in #7385 without an encoding. The sibling _read helper directly above it already passes encoding = "utf-8", so this just makes the two agree.

Worth fixing promptly because CI for a pull_request runs the merge commit, so every open PR inherits this failure even when its own head does not contain the helper. It is currently red on unrelated PRs for that reason.

Verified on a clean main worktree: the guard test fails before, and tests/test_source_read_encoding.py plus the full tests/studio/test_model_picker_contracts.py (66 tests) pass after.

_read_backend landed in #7385 without an encoding, so it falls back to the
platform default and breaks on Windows the moment a backend file it reads gains
a non-ASCII byte. tests/test_source_read_encoding.py guards exactly this and is
currently failing on main, which turns Repo tests (CPU) red on every open PR
whose CI runs the merge commit.

The sibling _read helper directly above already passes encoding = "utf-8".
Three test_start.py cases assert on plain substrings of result.output, e.g.
"Invalid value for '--gpu-memory-mode'". Typer renders parameter errors through
Rich, which emits ANSI escapes as soon as FORCE_COLOR is set, so the substring is
split across escape sequences and the assertion fails even though the message is
present. They pass locally and fail in CI purely because the runner exports
FORCE_COLOR; click, typer and rich are the same versions in both.

Setting NO_COLOR alone does not help, FORCE_COLOR still wins, so the autouse
fixture removes FORCE_COLOR and CLICOLOR_FORCE as well.

#7598 only recently started running unsloth_cli/tests in Backend CI, which is why
this surfaced now. Verified: the whole suite is 748 passed with and without
FORCE_COLOR=1.
@danielhanchen danielhanchen changed the title Read the backend source as utf-8 in the model-picker contract test Fix two pre-existing Backend CI failures blocking every open PR Jul 30, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Added a second, independent fix to this PR: three unsloth_cli/tests/test_start.py cases fail in CI but pass locally.

They assert plain substrings of result.output, e.g. "Invalid value for '--gpu-memory-mode'". Typer renders parameter errors through Rich, which emits ANSI escapes as soon as FORCE_COLOR is set, so the substring is split across escape sequences and in result.output stops matching even though the message is present.

Click, Typer and Rich are identical locally and in CI (8.4.2 / 0.27.0 / 15.0.0), so it is not version drift. Reproduced by exporting FORCE_COLOR=1 locally: the three fail, and pass again without it.

NO_COLOR alone does not fix it because FORCE_COLOR still wins, so the autouse fixture removes FORCE_COLOR and CLICOLOR_FORCE as well, per the NO_COLOR and FORCE_COLOR conventions.

#7598 only recently started running these in Backend CI, which is why it surfaced now. The whole suite is 748 passed, 4 skipped with and without FORCE_COLOR=1.

@danielhanchen
danielhanchen merged commit 1564ce4 into main Jul 30, 2026
51 of 52 checks passed
@danielhanchen
danielhanchen deleted the fix-model-picker-contracts-encoding branch July 30, 2026 08:53
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Jul 30, 2026
One conflict, in tests/studio/test_model_picker_contracts.py: unslothai#7639 added the
explicit encoding to _read_backend on main while this branch had already added
it with a comment explaining why. Same line either way, so the comment is kept.

Re-verified on the merged tree rather than assuming the merge was inert:
2141 passed and 3 skipped across tests/studio, 316 passed across
test_openai_auto_switch.py and test_api_monitor.py, typecheck clean,
111/111 node tests (main brought 8 of its own), production build clean.
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.

1 participant