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

Params + Results with nil Properties treated differently than Params + Results with empty Properties #6605

Closed
lbernick opened this issue May 1, 2023 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@lbernick
Copy link
Member

lbernick commented May 1, 2023

Expected Behavior

Our API doesn't differentiate between a map being nil and a map being empty.

The following two Task result definitions should be equivalent:

results:
  - name: my-result
results:
  - name: my-result
    properties: {}

Note: this is unrelated to the result values outputted by the TaskRun.

From the Go style guide: "Do not create APIs that force their clients to make distinctions between nil and the empty slice." (There's no equivalent guidance for maps but it seems like it should be the same?)

If we do want to differentiate this behavior we should at least make sure to document it clearly. I'm not sure why someone would want to declare an object param/result with no properties; it doesn't seem very meaningful.
Fixed in #6570 and #6578.

Actual Behavior

nil Properties -> defaults to string param/result:

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: nil-properties
spec:
  results:
    - name: object-results
  steps:
  - image: bash
    script: |
      echo -n "{\"IMAGE_URL\":\"ar.com\", \"IMAGE_DIGEST\":\"sha234\"}" > $(results.object-results.path)
$ k get task nil-properties -o yaml
...
spec:
  results:
  - name: object-results
    type: string
...

empty Properties -> defaults to object param/result

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: empty-properties
spec:
  results:
    - name: object-results
      properties: {}
  steps:
  - image: bash
    script: |
      echo -n "{\"IMAGE_URL\":\"ar.com\", \"IMAGE_DIGEST\":\"sha234\"}" > $(results.object-results.path)
$ k create -f ~/tkndefs/properties/nil-properties.yaml
Error from server (BadRequest): error when creating "/Users/leebernick/tkndefs/properties/nil-properties.yaml": admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: missing field(s): spec.results[0].object-results.properties
@lbernick lbernick added the kind/bug Categorizes issue or PR as related to a bug. label May 1, 2023
@JeromeJu
Copy link
Member

Suggesting this can be closed. Thanks @lbernick

@lbernick
Copy link
Member Author

@JeromeJu I think this bug can still be reproduced, even if conversion logic has been addressed

@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 14, 2023
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 13, 2023
@tekton-robot
Copy link
Collaborator

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link
Collaborator

@tekton-robot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

3 participants