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

Incorrect templating should result in error #627

Closed
bobcatfish opened this issue Mar 16, 2019 · 5 comments
Closed

Incorrect templating should result in error #627

bobcatfish opened this issue Mar 16, 2019 · 5 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@bobcatfish
Copy link
Collaborator

Expected Behavior

Whenever a user uses ${} templating syntax in their Task, if the value within the {} can't be resolved, an error should be returned to the user and the execution of any related TaskRuns or PipelineRuns should stop.

Actual Behavior

With these output resources:

  outputs:
    resources:
    - name: bucket
      type: storage
    - name: builtBaseImage
      type: image
    - name: builtEntrypointImage
      type: image
    - name: builtKubeconfigWriterImage
      type: image
    - name: builtCredsInitImage
      type: image
    - name: builtGitInitImage
      type: image
    - name: builtNopImage
      type: image
    - name: builtBashImage
      type: image
    - name: builtGsutilImage
      type: image
    - name: builtControllerImage
      type: image
    - name: builtWebhookImage
      type: image

I tried to use this within one of my steps:

        ${inputs.params.pathToProject}/${outputs.resources.builtCredsInitImage}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest
        ${inputs.params.pathToProject}/${outputs.resources.builtGitInitImage}: ${inputs.params.imageRegistry}/${inputs.params.pathToProject}/build-base:latest

Values like ${outputs.resources.builtCredsInitImage} are incomplete b/c I actually should have been using attributes on the resource, e.g. ${outputs.resources.builtCredsInitImage.url}.

Instead of getting an error, the pod was created and tried to execute.

Steps to Reproduce the Problem

Additional Info

side note: how does a user escape the templating, if they need to literally use ${} in their Task?

@bobcatfish bobcatfish added kind/bug Categorizes issue or PR as related to a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Mar 16, 2019
@mikeykhalil
Copy link
Contributor

I was going to try to fix this issue, if nobody has jumped on this yet. Just getting my dev environment setup, but will report back once I make some progress.

I don't plan on tackling the problem mentioned in the Additional Info portion, though. That does seem like something that needs to be addressed. It almost feels like a separate issue though, if I understand it correctly.

@mikeykhalil
Copy link
Contributor

mikeykhalil commented Apr 3, 2019

Haven't had a ton of time to look at this. I added a few tests to pipeline/pkg/templating/templating_test.go based off this issue. I would have expected these new tests to fail, but they passed without any source code changes. So I'm guessing that if the issue is still present, it's further up in the call stack and is just a matter of handling the error from the templating package properly.

Anyways, I will try to find some time tomorrow to take a deeper look.

@mikeykhalil
Copy link
Contributor

This issue ended up being a bit more complex than we originally had thought.

Seems like there are some more involved design decisions that would have to be made in order to correctly validate variables at task creation time.

Feel free to follow the discussion on this PR for more details:

#765

@bobcatfish bobcatfish removed the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Sep 6, 2019
@vdemeester
Copy link
Member

@bobcatfish is it still valid ? I feel with the move to $() we now do more validation ?

@bobcatfish
Copy link
Collaborator Author

I'm not sure we do more validation @vdemeester but we are certainly relying on pipelineresources less, and i think pipelineresources are at the heart of the problem here, b/c you don't know what values are available for substitution until runtime. Feels safe to me to close this given #1673

pradeepitm12 referenced this issue in openshift/tektoncd-pipeline Jan 27, 2021
The update to knative is to pick up genreconciler and in turn requires us to
update our pipelines dependency to v0.13.2. I had to update the hack/ scripts,
remove some old pinned dependencies, and drop some deprecated functions and
flags. To get the webhook cert generation to work again, I had to replace
`sharedmain.MainWithContext` with `sharedmain.WebhookMainWihtConfig`.

Needed for #635 and fixes #627

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
savitaashture pushed a commit to savitaashture/pipeline that referenced this issue Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants