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

Missing validation against duplicated parameter names #4798

Closed
chuangw6 opened this issue Apr 26, 2022 · 3 comments
Closed

Missing validation against duplicated parameter names #4798

chuangw6 opened this issue Apr 26, 2022 · 3 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@chuangw6
Copy link
Member

chuangw6 commented Apr 26, 2022

Expected Behavior

Duplicated parameters (with same name) should be checked in both TaskRunSpec's params and TaskSpec's params

Example:

  • two bars in TaskRunSpec's params and two foos in TaskSpec's params
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  generateName: validation-
spec:
  params:
    - name: bar
      value: "xxx1"
    - name: bar
      value: "xxx2"
  taskSpec:
    params:
      - name: foo
        default: "value1"
      - name: foo
        default: "value2"
    results:
      - name: echo-output
        description: "see echo output"
    steps:
      - name: echo-params
        image: bash
        script: |
          set -e
          echo $(params.foo) | tee $(results.echo-output.path)

Actual Behavior

  • The duplicated two bars in TaskRunSpec's params will be captured and reported by this function. And this will cause the taskrun cannot be applied successfully and the following error message will be returned, which makes sense!
    Error from server (BadRequest): error when creating "dup.yaml": admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: expected exactly one, got both: spec.params[bar].name
    
  • But the duplicated two foos in TaskSpec's params will not be captured. With line 6-10 (TaskRunSpec's params) deleted, the taskrun will be executed successfully, but the param valuevalue2 is written to result. This is confusing i.e. why value2 is chose instead of value1?

Steps to Reproduce the Problem

  1. save the above yaml code into a file, and kubectl create -f <FILE_NAME>.yaml
  2. you can see the error message when apply it, which is mentioned in Actual Behavior's 1st point.
  3. delete line 6-10 (TaskRunSpec's params section), redo step1
  4. you can see the taskrun is executed successfully, but the weird value is written into taskresult, which is mentioned in Actual Behavior's 2nd point.

you can see taskresult by run kubectl get tr <taskrun_name> -o yaml

Additional Info

Kubernetes version:

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:41:01Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.6-gke.1503", GitCommit:"2c7bbda09a9b7ca78db230e099cf90fe901d3df8", GitTreeState:"clean", BuildDate:"2022-02-18T03:17:45Z", GoVersion:"go1.16.9b7", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.23) and server (1.21) exceeds the supported minor version skew of +/-1

Tekton Pipeline version:

Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

Client version: 0.21.0
Pipeline version: devel
@chuangw6 chuangw6 added the kind/bug Categorizes issue or PR as related to a bug. label Apr 26, 2022
@chitrangpatel
Copy link
Contributor

/assign

@chitrangpatel
Copy link
Contributor

Submitted a PR for this.

@jerop
Copy link
Member

jerop commented May 26, 2022

fixed in #4806 - thanks @chitrangpatel!

@jerop jerop closed this as completed May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants