Skip to content

improve validation of "--detach-keys" options#6742

Merged
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:validate_detachkeys
Jan 14, 2026
Merged

improve validation of "--detach-keys" options#6742
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:validate_detachkeys

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

Before this change, the detach-keys were not validated, and the code either fell back to the default sequence, or returned an obscure error if the invalid sequence would produce an error on the daemon;

Before this patch:

docker run -it --rm --detach-keys=shift-a,b busybox
unable to upgrade to tcp, received 400

With this patch:

docker run -it --rm --detach-keys=shift-a,b busybox
invalid detach keys (shift-a,b): Unknown character: 'shift-a'

Note that the "unable to upgrade to tcp, received 400" error is still something to be looked into; the client currently discards error messages coming from the daemon.

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Improve validation of `--detach-keys` command-line options

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter

codecov-commenter commented Jan 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/container/hijack.go 53.84% 5 Missing and 1 partial ⚠️
cli/command/container/start.go 60.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@thaJeztah thaJeztah force-pushed the validate_detachkeys branch from 3fd20e8 to f1722ec Compare January 14, 2026 12:49
Comment thread cli/command/container/hijack.go Outdated
Before this change, the detach-keys were not validated, and the code either
fell back to the default sequence, or returned an obscure error if the
invalid sequence would produce an error on the daemon;

Before this patch:

    docker run -it --rm --detach-keys=shift-a,b busybox
    unable to upgrade to tcp, received 400

With this patch:

    docker run -it --rm --detach-keys=shift-a,b busybox
    invalid detach keys (shift-a,b): Unknown character: 'shift-a'

Note that the "unable to upgrade to tcp, received 400" error is still
something to be looked into; the client currently discards error messages
coming from the daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the validate_detachkeys branch from f1722ec to fe31574 Compare January 14, 2026 15:57
@thaJeztah thaJeztah merged commit b43d4d8 into docker:master Jan 14, 2026
106 of 107 checks passed
@thaJeztah thaJeztah deleted the validate_detachkeys branch January 14, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment