Fix container --label rejecting values that contain "="#1978
Open
OrtegaMatias wants to merge 1 commit into
Open
Fix container --label rejecting values that contain "="#1978OrtegaMatias wants to merge 1 commit into
container --label rejecting values that contain "="#1978OrtegaMatias wants to merge 1 commit into
Conversation
`Parser.labels` split each `--label KEY=VALUE` entry on every '=' (`maxSplits: 2`) and rejected anything producing more than two parts, so a label whose value contained '=' — a common shape, e.g. a reverse-proxy router rule or a nested key=value config — failed with "invalid label format" even though such values are valid. Split on the first '=' only, matching how env values are already parsed (see `envFile`) and `docker run --label`. `container run --label config=key=value` now works.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
container run --label KEY=VALUErejected any label whose value contained a=, failing withinvalid label format— even though such values are valid and common (a reverse-proxy router rule, a nestedkey=valueconfig, a URL with a query string).docker run --labelsplits the label on the first=only.Fixes #1977.
Description
Parser.labelssplit each entry withsplit(separator: "=", maxSplits: 2)and only handled 1 or 2 parts, so a value containing=produced 3+ parts and hit the throwingdefaultbranch. Changed it tomaxSplits: 1(split on the first=only) — a label key cannot contain=, but the value may. This matches how the env-file parser already handles values (URL=https://foo.bar?baz=woo) anddocker run --label.Testing
Added
testLabelsValueWithEqualstoParserTest.swift, covering a plain value, a value with one=, a value with several=, and a key with no value.Transparency note: I could not run the in-repo test suite locally — this machine only has an Xcode 27 beta toolchain (which fails building a transitive dependency under strict concurrency) and the Command Line Tools, which lack the test frameworks. I confirmed the change compiles as part of the
ContainerAPIClienttarget and reproduced the fix against the cases above. CI runs the added test.