fix: correct lookup for environment variables in cache#808
Open
Skywalkr-dev wants to merge 1 commit into
Open
Conversation
kolyshkin
requested changes
May 22, 2026
Contributor
kolyshkin
left a comment
There was a problem hiding this comment.
You need to fix the commit subject.
432d54b to
5fcbb0f
Compare
Author
|
@kolyshkin sorry about the commit, does the current commit subject work |
kolyshkin
reviewed
May 22, 2026
Comment on lines
+325
to
+330
| name, _, found := strings.Cut(val, "=") | ||
| if found { | ||
| envMap[name] = i | ||
| } else { | ||
| // Fallback for variables without an '=' (rare, but possible) | ||
| envMap[val] = i |
Contributor
There was a problem hiding this comment.
nit: this can be simplified to a one-line patch:
for i, val := range env {
+ val, _, _ = strings.Cut(val, "=")
envMap[val] = i
Author
There was a problem hiding this comment.
nit: this can be simplified to a one-line patch:
for i, val := range env { + val, _, _ = strings.Cut(val, "=") envMap[val] = i
yup, that's much cleaner. I've updated the PR to use strings.Cut as suggested.
da3a1d4 to
0b2261d
Compare
The current implementation keys the environment cache by the full "NAME=VALUE" string. This causes the generator to treat updates to existing variables as new entries, leading to duplicate environment variables in the final configuration. This change switches the cache key to use only the variable name, ensuring that AddProcessEnv correctly updates existing values instead of appending them. Fixes opencontainers#798 Signed-off-by: Skywalkr-dev <snaveenbharath2005@gmail.com>
0b2261d to
3a0fa8a
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.
The current implementation keys the environment cache by the full "NAME=VALUE" string. This causes the generator to treat updates to existing variables as new entries, leading to duplicate environment variables in the final configuration.
This change switches the cache key to use only the variable name, ensuring that
AddProcessEnvcorrectly updates existing values instead of appending them.FIXES: #798
Signed-off-by: Skywalkr-dev snaveenbharath2005@gmail.com