Skip to content

🐛 fix(docker): surface proxy/daemon error bodies in exec errors - #77

Merged
scttbnsn merged 3 commits into
mainfrom
fix/exec-deny-reason
Jul 28, 2026
Merged

scttbnsn merged 3 commits into
mainfrom
fix/exec-deny-reason

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

From the portwing↔sockguard fit audit: when Docker access goes through sockguard, a denied exec returns 403 with the real reason in the body (e.g. exec denied: no commands are allowlisted) — portwing discarded it, so drydock's controller only ever saw a bare status code.

  • internal/docker/client.go: new dockerError/extractDockerErrorMessage helpers — every non-2xx path now bound-reads the body (4 KiB cap), extracts Docker's JSON message when present, and includes it in the error. StartExec keeps its 101-wording and appends the body message.
  • internal/edge: no change needed — failStart already interpolates the error, so the denial reason now reaches the controller's exec_end frame (covered by a new test).
  • New examples/docker-compose.edge-with-exec.yml + preset copy: the Edge-Mode pairing that actually supports exec (portwing-with-exec.yaml); the plain preset denies all exec by design. README + CHANGELOG updated.
  • Tests: error-body extraction, per-call-site 403 propagation, 4 KiB truncation, edge exec_end reason forwarding. Coverage 96.3% total (internal/docker 95.8%, internal/edge 96.9%, new helpers 100%), floor 96 passes.

Changelog

  • ✨ Added bounded Docker error-body parsing with Docker JSON message extraction.
  • ✨ Added tests for error propagation, truncation, StartExec, and edge exec_end forwarding.
  • ✨ Added Edge-Mode Docker Compose and Sockguard presets with exec enabled.
  • 🔧 Changed README documentation to explain default exec denial and the exec-enabled setup.
  • 🐛 Fixed Docker and controller errors to preserve proxy/daemon denial reasons and HTTP status codes.
  • 🗑️ Removed obsolete response-body helpers and related tests.

Concerns

  • Verify the new Edge-Mode compose example’s Drydock configuration and secret/key setup against supported deployment requirements.
  • Confirm the 4 KiB truncation behavior is sufficient for all expected Docker/proxy error responses.

scttbnsn added 2 commits July 28, 2026 18:49
Non-2xx Docker API responses (CreateExec, StartExec, ResizeExec,
InspectContainer, and siblings in internal/docker/client.go) previously
discarded the response body and returned only a bare status code. When
sockguard denies exec with a 403, the real reason ("exec denied: no
commands are allowlisted") never reached the edge exec_end frame sent to
the controller. A shared dockerError/extractDockerErrorMessage helper now
reads a bounded (4 KiB) slice of the body, extracts Docker's
{"message":"..."} JSON shape (or falls back to the raw trimmed body), and
every non-2xx path in the file uses it consistently. The edge failStart
path already interpolates err into the exec_end reason, so the enriched
message reaches Drydock without further changes to internal/edge/tunnel.go.

- ✨ examples/docker-compose.edge-with-exec.yml + sockguard-with-exec.yaml:
  pairs edge mode with sockguard's portwing-with-exec.yaml preset, since
  the plain preset denies all exec by design.
- 📝 README: point at the new example from the with-sockguard section and
  call out the exec-denial-by-default behavior.
- 📝 CHANGELOG: Added/Fixed entries under Unreleased.

Test changes: removed readAndCloseBody (now dead after the refactor) and
its four dedicated unit tests; updated TestResizeExec_BodyReadError and
TestStartExec_Non101Response assertions to match the new error format.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@scttbnsn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 483f0f92-2019-4bef-8d4d-c4ed0c91b594

📥 Commits

Reviewing files that changed from the base of the PR and between 2864279 and 82935d5.

📒 Files selected for processing (2)
  • README.md
  • internal/docker/client_unix_test.go
📝 Walkthrough

Walkthrough

Docker client error responses are now read with a size limit, parsed for Docker message fields, and returned through consistent error formatting across container, exec, event, info, and stats operations. Tests cover parsing, propagation, truncation, Unix-socket failures, and controller exec error reasons. New Sockguard and Docker Compose examples enable Portwing edge-mode exec traffic, while the README documents the default denial and alternate configuration.

Possibly related PRs

  • CodesWhat/portwing#61: Both changes modify Docker client error handling and overlap in how Docker error details are processed.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/exec-deny-reason

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/docker/client_unix_test.go`:
- Around line 204-205: Update the shortTempDir helper used by this Unix-socket
test to create temporary directories with the mandated "lk" prefix via
os.MkdirTemp("", "lk"), while preserving the existing cleanup and return
behavior.

In `@README.md`:
- Line 226: Update the README description of the default sockguard preset to
state that denied exec requests return HTTP 403 with the reason “exec denied: no
commands are allowlisted,” rather than describing the response as a bare 403;
preserve the surrounding guidance about the edge-with-exec preset and controller
error propagation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ab9cca15-7bfe-45b1-881d-42429663adbd

📥 Commits

Reviewing files that changed from the base of the PR and between a8f6a05 and 2864279.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (9)
  • README.md
  • examples/docker-compose.edge-with-exec.yml
  • examples/sockguard-with-exec.yaml
  • internal/docker/client.go
  • internal/docker/client_dockererror_test.go
  • internal/docker/client_errors_test.go
  • internal/docker/client_test.go
  • internal/docker/client_unix_test.go
  • internal/edge/exec_docker_test.go
💤 Files with no reviewable changes (1)
  • internal/docker/client_test.go

Comment thread internal/docker/client_unix_test.go Resolved
Comment thread README.md Resolved

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scttbnsn
scttbnsn merged commit 5d51c11 into main Jul 28, 2026
27 checks passed
scttbnsn added a commit that referenced this pull request Jul 29, 2026
…es (#78)

- README.md: deny-all preset returns 403 "not allowed by portwing preset",
  not the with-exec preset's "exec denied: no commands are allowlisted";
  clarify the denial reason now reaches portwing's exec error and the
  exec_end reason forwarded to the controller (drydock-side display pending)
- examples/docker-compose.edge-with-exec.yml: same correction in the header
  comment, plus a pointer to sockguard's audited tri-tool bundle
- examples/README.md: index docker-compose.edge-with-exec.yml and
  sockguard-with-exec.yaml, added in #77 but missing from the table
- docs/content/docs/drydock-integration.mdx: document the exec_* Edge Mode
  message types and note exec_end's reason field
@scttbnsn
scttbnsn deleted the fix/exec-deny-reason branch August 4, 2026 18:53
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.

3 participants