Split --label on the first '=' only so values may contain '='#1999
Open
chengboonrong wants to merge 1 commit into
Open
Split --label on the first '=' only so values may contain '='#1999chengboonrong wants to merge 1 commit into
chengboonrong wants to merge 1 commit into
Conversation
chengboonrong
force-pushed
the
fix/label-value-equals
branch
from
July 23, 2026 13:25
e002029 to
d235642
Compare
`Parser.labels` split each entry with `split(separator: "=", maxSplits: 2)` and only handled 1 or 2 parts, so any `--label KEY=VALUE` whose value contained a `=` produced 3+ parts and was rejected with "invalid label format". This blocked common values such as reverse-proxy router rules (`traefik.http.routers.x.rule=Host(...)`) and nested `key=value` config. Split on the first `=` only (`maxSplits: 1`), matching `docker run --label` and the env-file parser in this same file. Everything after the first `=` is kept verbatim as the value; entries without a `=` still map to an empty value. Fixes apple#1977 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Chris Cheng <chengchris8715@gmail.com>
chengboonrong
force-pushed
the
fix/label-value-equals
branch
from
July 23, 2026 13:38
d235642 to
77d2cd8
Compare
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.
Summary
container run --label KEY=VALUErejected any label whose value contained a=:This blocks common real-world values such as reverse-proxy router rules
(
--label 'traefik.http.routers.x.rule=Host(ex.com)') and nestedkey=valueconfiguration.Root cause
Parser.labelssplit each entry withsplit(separator: "=", maxSplits: 2)andonly handled 1 or 2 parts, throwing for anything else. A value containing a
=produces 3+ parts and hits the
default(throw) branch.Fix
Split on the first
=only (maxSplits: 1), keeping everything after it asthe value. This matches
docker run --labeland the env-file parser already inthis same file (
URL=https://foo.bar?baz=woois accepted). Entries with no=still map to an empty value; behavior for all previously-valid labels is
unchanged.
Tests
Adds a
ParserTestcase covering a value with=, a Traefik-style rule, aplain
key=value, a bare key, and an empty value. Verified locally:swift build,swift format lint --strict, and the parser tests all pass.Fixes #1977
🤖 Generated with Claude Code