[PR #104] [MERGED] fix(stream): version-gate multiplexed Content-Type and apply to exec-start #104

Closed
opened 2026-10-15 12:52:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/104
Author: @JBailes
Created: 7/1/2026
Status: ✅ Merged
Merged: 7/1/2026
Merged by: @JBailes

Base: main ← Head: fix/multiplexed-stream-version-gate


📝 Commits (1)

  • 89f73d9 fix(stream): version-gate multiplexed Content-Type and apply to exec-start

📊 Changes

3 files changed (+115 additions, -40 deletions)

View changed files

📝 internal/api/attach_response_test.go (+55 -16)
📝 internal/api/containers.go (+56 -14)
📝 internal/api/exec.go (+4 -10)

📄 Description

Byte-exact follow-ups from the #103 roundtable review, covering the two remaining stream-Content-Type parity gaps.

1. Version-gate the multiplexed media type

moby advertises the multiplexed stream type only for !Tty && version >= 1.42; the type was introduced in API v1.42, so a client that negotiated an older version predates it and must get raw-stream (it demuxes from Config.Tty, not the header). #103 advertised multiplexed-stream unconditionally.

streamContentType(r, tty) now consults the client's negotiated API version from the /v{version}/ path prefix (absent = current daemon = multiplexed-eligible) via new apiVersionAtLeast / compareDottedVersions helpers (numeric compare, so 1.9 < 1.10).

2. Apply the shared helper to exec-start

POST /exec/{id}/start still hardcoded raw-stream in both hijack branches, even though non-TTY exec streams stdcopy-multiplexed frames (runExecMux) — the same Content-Type/framing mismatch #103 fixed for attach/logs. It now routes through writeHijackPreamble + streamContentType(r, rec.Tty), so exec advertises the correct (version-gated) media type. The 101-vs-200 behavior from #98 is unchanged.

After this PR all four stream sites — attach, logs (×2), exec-start — resolve the media type through one helper.

Tests

internal/api/attach_response_test.go:

  • streamContentType across version × tty (no-version, 1.24/1.41 → raw, 1.42/1.43/1.50 → multiplexed, tty always raw).
  • compareDottedVersions incl. the numeric-not-lexicographic case (1.9 vs 1.10).
  • writeHijackPreamble updated for the new (w, upgrade, contentType) signature.

Full go test ./..., go vet, gofmt clean locally.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/104 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 7/1/2026 **Status:** ✅ Merged **Merged:** 7/1/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/multiplexed-stream-version-gate` --- ### 📝 Commits (1) - [`89f73d9`](https://github.com/games-on-whales/LXC2Docker/commit/89f73d990f83bf36047c3c296c8a9d956a619185) fix(stream): version-gate multiplexed Content-Type and apply to exec-start ### 📊 Changes **3 files changed** (+115 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `internal/api/attach_response_test.go` (+55 -16) 📝 `internal/api/containers.go` (+56 -14) 📝 `internal/api/exec.go` (+4 -10) </details> ### 📄 Description Byte-exact follow-ups from the #103 roundtable review, covering the two remaining stream-Content-Type parity gaps. ## 1. Version-gate the multiplexed media type moby advertises the multiplexed stream type only for `!Tty && version >= 1.42`; the type was introduced in API v1.42, so a client that negotiated an older version predates it and must get `raw-stream` (it demuxes from `Config.Tty`, not the header). #103 advertised `multiplexed-stream` unconditionally. `streamContentType(r, tty)` now consults the client's negotiated API version from the `/v{version}/` path prefix (absent = current daemon = multiplexed-eligible) via new `apiVersionAtLeast` / `compareDottedVersions` helpers (numeric compare, so `1.9 < 1.10`). ## 2. Apply the shared helper to exec-start `POST /exec/{id}/start` still hardcoded `raw-stream` in both hijack branches, even though non-TTY exec streams stdcopy-multiplexed frames (`runExecMux`) — the same Content-Type/framing mismatch #103 fixed for attach/logs. It now routes through `writeHijackPreamble` + `streamContentType(r, rec.Tty)`, so exec advertises the correct (version-gated) media type. The 101-vs-200 behavior from #98 is unchanged. After this PR all four stream sites — attach, logs (×2), exec-start — resolve the media type through one helper. ## Tests `internal/api/attach_response_test.go`: - `streamContentType` across version × tty (no-version, 1.24/1.41 → raw, 1.42/1.43/1.50 → multiplexed, tty always raw). - `compareDottedVersions` incl. the numeric-not-lexicographic case (`1.9` vs `1.10`). - `writeHijackPreamble` updated for the new `(w, upgrade, contentType)` signature. Full `go test ./...`, `go vet`, `gofmt` clean locally. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:52:03 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#104
No description provided.