This repository was archived by the owner on Jan 8, 2024. It is now read-only.
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.
What problem is this solving?
This addresses the panic within #1704.
The problem here is that, if we embed a pointer to a private struct, and the private struct is nil, the caller has no way to determine if the embedded struct's values are safe to access.
This manifests here:
waypoint/internal/cli/base.go
Line 253 in 124f455
There is no way to determine of
c.cfg.Runner
is safe to access.c.cfg
can be non-nil on its own, but it will become nil when inspectingc.cfg.Runner
if the embedded*hclConfig
is nil.A simplified example of the problem:
https://play.golang.org/p/sbAPT2HGJqW
If hclConfig is not a pointer, we won't get a nil pointer deference when looking at its fields.
Is this change safe?
I believe so - we don't have any methods on hclConfig that require it to be a pointer. We also never statefully maniuplate it outside of the context of
cfg
, as far as I can see. I've tested this locally and it doesn't seem to break anything.