Skip to content

fix(client): send minimal JSON body on empty POSTs to avoid HTTP 411 - #316

Merged
sethtroisi merged 1 commit into
googlecolab:mainfrom
Milabo-HRH:fix/empty-post-411-content-length
Dec 3, 2026
Merged

sethtroisi merged 1 commit into
googlecolab:mainfrom
Milabo-HRH:fix/empty-post-411-content-length

Conversation

@Milabo-HRH

Copy link
Copy Markdown
Contributor

Fixes #299.

Problem

POST /tun/m/assign and POST /tun/m/unassign issue body-less POST requests via Client._issue_request. On some networks / Google Frontend edges, empty POST requests are rejected with HTTP 411 Length Required (POST requests require a Content-length header), even when requests emits Content-Length: 0.

Fix

In Client._issue_request, when method.upper() == "POST" and no request body (data, json, or files) is provided, default to data=b"{}". Callers that pass an explicit body and non-POST requests are untouched.

Testing

  • Added unit tests in tests/test_client.py covering body-less POSTs (including assign and unassign), preservation of explicit data/json payloads, and unchanged GET requests.
  • ruff format --check src/colab_cli/client.py tests/test_client.py -> clean.
  • pytest -q tests -> 681 passed, 27 skipped (excluding the headless D-Bus SecretService test in WSL).

@sethtroisi

Copy link
Copy Markdown
Collaborator

I'm surprised this happens but it's easy to fix so lets do it!

Thanks @Milabo-HRH for seeing the issue and writing up this PR!

@sethtroisi
sethtroisi merged commit e758b03 into googlecolab:main Dec 3, 2026
7 checks passed
doggy8088 added a commit to doggy8088/google-colab-cli that referenced this pull request Dec 4, 2026
上游變更:googlecolab#315 `colab stop` 端點備援(以伺服器端點停止孤兒分配,`_teardown` 失敗時保留本地記錄並提示重試)、googlecolab#316 空 POST 以最小 JSON 內文避免 HTTP 411。
更新譯文:docs/01_session_management.md、docs/05_run_command.md(log、端點備援說明、拆除流程與測試案例)。
其餘檔案隨 main 鏡像;常駐偏離 .github/workflows/pages.yml、scripts/build_site.py 保留。
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.

assign and unassign fail with HTTP 411 Length Required (empty POST rejected)

2 participants