Skip to content

fix: surface friendly error on 412 GPU/TPU allocation instead of a traceback - #112

Open
aadi-joshi wants to merge 1 commit into
googlecolab:mainfrom
aadi-joshi:fix-412-friendly-error
Open

fix: surface friendly error on 412 GPU/TPU allocation instead of a traceback#112
aadi-joshi wants to merge 1 commit into
googlecolab:mainfrom
aadi-joshi:fix-412-friendly-error

Conversation

@aadi-joshi

Copy link
Copy Markdown

Fixes #73

client.assign() catches a 412 from the backend and raises TooManyAssignmentsError (client.py lines 274-277). That exception was never caught anywhere else. Both colab new --gpu and colab run --gpu let it fall through as a raw traceback. colab ssh's auto-create path calls into session.py's new(), so it hit the same bug.

The 400 case (no quota or entitlement) already had a friendly handler in session.py and run.py. I added a matching handler for 412 in both files, right next to the existing one.

The message does not assume the cause is only accelerator scarcity, since TooManyAssignmentsError can also mean too many active sessions on a plain CPU request. It suggests colab stop to free a session, retrying, or trying a different accelerator.

Testing

  • Added a unit test in test_client.py confirming assign() converts a 412 into TooManyAssignmentsError.
  • Added CLI tests in test_cli.py and test_run.py mirroring the existing 400 tests, confirming the friendly message shows and the command exits non-zero instead of raising a traceback.
  • Ran the full suite: uv run pytest tests/, 345 passed.
  • Ran uv run ruff check . on the changed files, clean.

Happy to adjust the message wording if you would prefer something different.

…aceback

client.assign() already converts a 412 from the backend into
TooManyAssignmentsError, but nothing caught it. colab new --gpu and
colab run --gpu let it fall through as a raw traceback instead of an
actionable message. colab ssh's auto-create path hits the same bug
since it calls into session.py's new().

Catch it in both commands and print a message explaining the likely
cause (too many active sessions or a temporary usage/capacity limit),
mirroring the existing friendly-message pattern used for 400 errors.

Fixes googlecolab#73
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.

412 on GPU allocation is mislabeled as TooManyAssignmentsError and surfaced as an uncaught traceback

1 participant