Repository navigation
[Bugfix] Fix wrong exception type and unbound variable guard - #5063
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9f57599. Configure here.
|
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. |
Wauplin
approved these changes
Oct 2, 2026
Contributor
|
This PR has been shipped as part of the v2.2.0 release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes two minor bugs:
ValueErrorwhen the checkpoint path doesn't exist, but the docstring documentsFileNotFoundError. Downstream code catchingFileNotFoundErrorwould miss this. Changed toFileNotFoundError.UnboundLocalErrorbecause name is only assigned inside the loop. Added an early guard that raises a descriptiveValueErrorfor empty input.No behavior change for valid inputs.
ruff check,ruff format --check, and the generated-file checks (check_static_imports,generate_async_inference_client,generate_cli_reference) pass.Note
Low Risk
Two minimal fixes (one line changed, two lines added). No API surface or signature changes.
_torch.py —
ValueError→FileNotFoundErroron line 440. Only affects the already-failing case when the path doesn't exist, now matches the documented exception type.repocard_data.py — Added guard
if not model_index: raise ValueError(...)before the loop. PreventsUnboundLocalErroron empty model_index lists (e.g. from a model card withmodel-index: []).Closes #5062
Closes #5061
Note
Low Risk
Narrow exception-type and input-validation fixes only on already-failing paths; no API signature changes and valid inputs behave the same.
Overview
Two small error-handling fixes with no change for valid inputs.
load_torch_modelnow raisesFileNotFoundErrorwhen the checkpoint path is missing, matching the documented API and letting callers that catchFileNotFoundErrorhandle missing paths correctly (previouslyValueError). TheValueErrordocstring entry is narrowed to checkpoint format issues only.model_index_to_eval_resultsrejects an emptymodel_indexup front with a clearValueErrorinstead of failing later withUnboundLocalErrorwhenmodel-index: []appears on a model card.Tests cover both behaviors.
Reviewed by Cursor Bugbot for commit 8f4996f. Bugbot is set up for automated code reviews on this repo. Configure here.