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

Profile patch with invalid op reports "invalid path" instead of "invalid op" #5259

Open
TBBle opened this issue Jan 21, 2021 · 2 comments
Open
Labels
area/errors area/yaml-docs kind/friction Issues causing user pain that do not have a workaround needs-actionable-error The error shown does not have a clear next step. priority/p2 May take a couple of releases

Comments

@TBBle
Copy link
Contributor

TBBle commented Jan 21, 2021

Expected behavior

An invalid op in the profile.patches list should complain that the op is invalid, i.e.,

> skaffold dev -p NodePort
applying profiles: applying profile "NodePort": invalid op: delete

Actual behavior

An invalid op in the profile.patches list complains that the path is invalid, i.e.

> skaffold dev -p NodePort
applying profiles: applying profile "NodePort": invalid path: /deploy/helm/releases/0/setValues/service.port

It wasn't until I went to look at the spec after about a half-hour of trying to rewrite, rephrase, or simply respell the path, and then hunting through Skaffold bug reports, that I went to look at the JSON Patch site, and discovered that the op is remove, not delete.

The path is not invalid.

Information

  • Skaffold version: v1.17.2
  • Operating system: Microsoft Windows [Version 10.0.19041.685]
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2beta10
kind: Config
metadata:
  name: my-server
build:
  artifacts:
    - image: my-server
      docker: {}
deploy:
  helm:
    releases:
      - name: my-server
        chartPath: charts/my-server
        artifactOverrides:
          image: my-server
        setValues:
          service.type: LoadBalancer
          service.port: 8000
profiles:
  - name: NodePort
    patches:
      - op: replace
        path: /deploy/helm/releases/0/setValues/service.type
        value: NodePort
      - op: delete
        path: /deploy/helm/releases/0/setValues/service.port

Steps to reproduce the behavior

  1. an empty directory containing only the skaffold.yaml above.
  2. skaffold dev -p NodePort
  3. Profit
@TBBle
Copy link
Contributor Author

TBBle commented Jan 21, 2021

The fix should be simple enough. Instead of making up an error if anything is wrong with the patch attempt, perhaps skaffold should propagate the error we got from yamlpatch and show the user that.

If possible, having the config schema actually validate that the optional op is one of the allowed values would also have caught this, I believe. I don't see that capacity right now, but perhaps adding something like yamltags:"enum=add=remove=replace=move=copy=test" might be worthwhile?

TBBle pushed a commit to TBBle/skaffold that referenced this issue Jan 22, 2021
The faulty JSONPatch tests now ensure that the resulting error message
actually mentions the faulty value.

Fixes: GoogleContainerTools#5259

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
TBBle pushed a commit to TBBle/skaffold that referenced this issue Jan 22, 2021
The faulty JSONPatch tests now ensure that the resulting error message
actually mentions the faulty value.

Fixes: GoogleContainerTools#5259

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
@briandealwis briandealwis added area/errors area/yaml-docs kind/friction Issues causing user pain that do not have a workaround needs-actionable-error The error shown does not have a clear next step. priority/p1 High impact feature/bug. labels Jan 25, 2021
@briandealwis briandealwis added priority/p2 May take a couple of releases and removed priority/p1 High impact feature/bug. labels Feb 1, 2021
@tejal29
Copy link
Contributor

tejal29 commented Feb 23, 2021

Thanks @TBBle for opening an issue with fixes.
Please let us know on how we could help you get the change in faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/errors area/yaml-docs kind/friction Issues causing user pain that do not have a workaround needs-actionable-error The error shown does not have a clear next step. priority/p2 May take a couple of releases
Projects
None yet
3 participants