[release/13.0] Fix DockerComposeEnvironment duplicating image names in .env file #12539
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.
Backport of #12310 to release/13.0
/cc @captainsafia @copilot
Customer Impact
This is a regression from the last release. When updating environment variables in .env files with
onlyIfMissing: false, duplicate key entries are generated in the file instead of updating the existing key. This causes invalid .env files with multiple definitions of the same variable and breaks Docker container configuration.Testing
Unit tests and manual validation.
Risk
Low. The fix refactors key parsing into a reusable
TryParseKeymethod and adds logic to update existing key values in-place whenonlyIfMissing: false. The change is localized to theEnvFile.Addmethod and maintains backward compatibility for theonlyIfMissing: truecase.Regression?
Yes - this fixes a regression where duplicate keys were created in .env files.