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

Empty ReplacementTransformer source value causes panic #620

Closed
drewwalters96 opened this issue Aug 17, 2021 · 2 comments
Closed

Empty ReplacementTransformer source value causes panic #620

drewwalters96 opened this issue Aug 17, 2021 · 2 comments
Assignees
Labels
bug Something isn't working priority/medium Default priority for items
Milestone

Comments

@drewwalters96
Copy link
Contributor

drewwalters96 commented Aug 17, 2021

Describe the bug
Operators can specify a string source value in the ReplacementTransformer rather than a path. For example:

replacements:
- source:
    value: "http://[email protected]"
  target:
    objref:
      kind: Deployment
      name: source-controller
    fieldrefs: ["spec.template.spec.containers[name=manager].env[name=http_proxy].value%REPLACEMENT_HTTP_PROXY%"]

When this source value is an empty string, airshipctl panics:

replacements:
- source:
    value: ""
  target:
    objref:
      kind: Deployment
      name: source-controller
    fieldrefs: ["spec.template.spec.containers[name=manager].env[name=http_proxy].value%REPLACEMENT_HTTP_PROXY%"]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbc799e]

goroutine 1 [running]:
opendev.org/airship/airshipctl/pkg/document/plugin/replacement.getValue(0xc000b62800, 0x98, 0x100, 0xc0003046c0, 0xd4a3a0, 0xc0004ab980, 0xd462e0)
        opendev.org/airship/airshipctl@/pkg/document/plugin/replacement/transformer.go:89 +0x4e
opendev.org/airship/airshipctl/pkg/document/plugin/replacement.(*plugin).Filter(0xc0004ab980, 0xc000b62800, 0x98, 0x100, 0x0, 0x0, 0xd7f7b4, 0x32, 0x1556760)
        opendev.org/airship/airshipctl@/pkg/document/plugin/replacement/transformer.go:72 +0x9a
main.main.func1(0xc0000ee5a0, 0x0)
        opendev.org/airship/airshipctl@/krm-functions/replacement-transformer/main.go:25 +0x7d
sigs.k8s.io/kustomize/kyaml/fn/framework.execute(0xc0000ee5a0, 0xc000283b80, 0xc000224840, 0x15556f0, 0x0, 0x0, 0xc000297d08, 0xc000297d30)
        sigs.k8s.io/kustomize/[email protected]/fn/framework/framework.go:560 +0x128
sigs.k8s.io/kustomize/kyaml/fn/framework.Command.func1(0xc000224840, 0x15556f0, 0x0, 0x0, 0x0, 0x0)
        sigs.k8s.io/kustomize/[email protected]/fn/framework/framework.go:258 +0x8a
github.com/spf13/cobra.(*Command).execute(0xc000224840, 0xc0000901b0, 0x0, 0x0, 0xc000224840, 0xc0000901b0)
        github.com/spf13/[email protected]/command.go:842 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc000224840, 0xc000283b80, 0xc000224840, 0xc00004e750)
        github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:887
main.main()
        opendev.org/airship/airshipctl@/krm-functions/replacement-transformer/main.go:28 +0xed
couldn't execute function: exit status 2

Steps To Reproduce
Use an empty string as a source in a ReplacementTransformer.

Expected behavior
Should be able to use an empty string as a replacement source without airshipctl panicking.

@drewwalters96 drewwalters96 added bug Something isn't working triage Needs evaluation by project members labels Aug 17, 2021
@gtsteffaniak
Copy link

assign to me

@eak13 eak13 removed the triage Needs evaluation by project members label Aug 18, 2021
@eak13 eak13 added this to the v2.1 milestone Aug 18, 2021
@eak13 eak13 added the priority/medium Default priority for items label Aug 18, 2021
@gtsteffaniak
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority/medium Default priority for items
Projects
None yet
Development

No branches or pull requests

3 participants