Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix override of existing values in prepend & append #581

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

nicolasbender
Copy link
Contributor

Summary

Currently, when using NewFormattedMapFromEnvironment(environment), entries like "$KEY:value" are overwritten by the last loop execution when using both append and prepend on the same $KEY. This fix appends and prepends values to entries which are already existing.

Use Cases

We stumbled upon this in the following PR: paketo-buildpacks/npm-install#688 (comment). Integration tests in this project are not working because they check for specific log entries written with NewFormattedMapFromEnvironment(environment), which yield the wrong result, because they overwrite "$KEY:value" when append and prepend are used on the same $KEY.

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

Copy link
Contributor

@c0d1ngm0nk3y c0d1ngm0nk3y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Mostly a matter of taste, but existingValue.(string) might cause a panic.

scribe/formatted_map.go Outdated Show resolved Hide resolved
scribe/formatted_map.go Outdated Show resolved Hide resolved
@robdimsdale robdimsdale added the semver:patch A change requiring a patch version bump label Jun 26, 2024
@robdimsdale
Copy link
Member

Hello and welcome, @nicolasbender !

This broadly looks good - thanks for adding test coverage - and I'd like to see this PR incorporate the changes suggested by @c0d1ngm0nk3y . I don't want to just merge them in myself in case you have opinions on them.

@ForestEckhardt
Copy link
Contributor

@nicolasbender To be clear. This will only affect the way these environment variables are ultimately logged no functionality will change as the setting of environment variables from the files generated is done by the lifecycle. I think that this is still a great fix I just wanted to lay that out cause it is unclear to me in the write up that is the intended outcome.

@nicolasbender
Copy link
Contributor Author

nicolasbender commented Jul 11, 2024

@ForestEckhardt

This will only affect the way these environment variables are ultimately logged

Yes, we are aware of that. The issue we had with this was only in some integration tests from the npm-install buildpack which tested the outcome of the logged result and not the result itself (paketo-buildpacks/npm-install#688 (comment)). And since the logging did not work properly, the integration tests failed.

@ForestEckhardt
Copy link
Contributor

Perfect!

@ForestEckhardt ForestEckhardt merged commit b6530bc into paketo-buildpacks:v2 Jul 12, 2024
7 checks passed
@nicolasbender nicolasbender deleted the fix-formatted-map branch July 15, 2024 08:19
@nicolasbender
Copy link
Contributor Author

nicolasbender commented Jul 19, 2024

Hi @ForestEckhardt @robdimsdale, thanks for merging! Is it possible to release this change in a patch version? Although this is a very small change, this PR is blocked until the next release of packit including this change.

@c0d1ngm0nk3y
Copy link
Contributor

@paketo-buildpacks/tooling-maintainers Are there any plans on releasing packit?

@mhdawson
Copy link
Member

mhdawson commented Aug 8, 2024

@sophiewigmore not sure if you are involved in this repo, but getting a release would be great to unlock the Node.js pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants