Env vars given with --env/--env-value-from/--env-file are silently dropped when they can't be matched in the command line
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start by reading UpdateEnvVars in pkg/flags/podspec_helper.go and trace how the --env, --env-value-from, and --env-file entries are collected and ordered from command-line arguments. Ensure matching affects order only, so unmatched entries are still applied. Done means the reported short-flag, repeated-name, and plugin cases retain all requested variables.
Written by the indexing model from the issue text.
Description
Bug report
kn service create / kn service update silently drop some of the environment variables given with --env, --env-value-from or --env-file. The command succeeds, but the variables are missing from the created revision.
UpdateEnvVars in pkg/flags/podspec_helper.go determines the order of the env vars by walking os.Args and matching every argument against the next expected NAME=value entry of each flag. Any entry that can't be matched this way is never added to the container. This happens for example when:
- the short flag is used without a separator, e.g.
-eFOO=bar(only-e FOO=bar,-e=FOO=barand--env=FOO=barare recognized), - a name is given more than once, e.g.
-e A=1 -e B=2 -e A=3: the matching gets stuck onA=3whileB=2passes by, soBis lost, - the
pkglibrary is used from another binary (e.g. a plugin) whoseos.Argsdon't contain the kn flags at all: then no env var is set.
Expected behavior
All requested environment variables are set. Matching against the arguments should only influence the order, never whether a variable is applied.
Steps to reproduce the problem
kn service create foo --image gcr.io/knative-samples/helloworld-go -eFOO=bar --no-wait
kn service describe foo -o yaml | grep -A3 env # FOO is missing
kn service create bar --image gcr.io/knative-samples/helloworld-go -e A=1 -e B=2 -e A=3 --no-wait
kn service describe bar -o yaml | grep -A5 env # only A=3, B is missing
kn version
main (f2bfc7f3)
Knative (serving/eventing) version
Nightly
- Dominant language
- Go
- Stars
- 387
- Forks
- 278
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from knative/client
-
kn secret create --tls-cert creates the certificate under the wrong keyPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
--node-affinity panics without Type and wipes existing affinity settingsPossibly taken @NopeCharon claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
kind/bug lifecycle/stale triage/accepted
Difficulty 3/5 1-2 days Newbie friendliness 35/100
knative/client#1965 · 4 comments ·
Maintainers usually reply within 1 day
-
[48h Knative] KServe pluginMay be free again @sharmaansh21 claimed this 1070 days ago, and no pull request is open. Openknative48h triage/accepted
knative/client#1866 · 4 comments · 1 reaction · 2 assignees ·
Maintainers usually reply within 1 day
-
CLI: add support for experimental new filters API in triggerMay be free again @JuneOh710 claimed this 1071 days ago, and no pull request is open. Openkind/feature triage/accepted
Difficulty 3/5 1-2 days Newbie friendliness 45/100
knative/client#1833 · 6 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area/ambient
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
`autorelease-tag.yml` starts after any run named "💡Fingerprints Update"Possibly taken @Mzack9999 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
projectdiscovery/wappalyzergo#184 ·
-
bug needs-triage P3 tier:2-standard
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
krakenhavoc/cmd_and_ctrl#4990 ·
Maintainers usually reply within 1 day