kpt icon indicating copy to clipboard operation
kpt copied to clipboard

Porch returns a generic error when Kptfile validation fails on render

Open ChristopherFry opened this issue 3 years ago • 2 comments

Porch always returns a generic error when a Kptfile validator function fails on render.

Expected behavior

Porch should return the fail message of the validator.

Actual behavior

Porch returns the following error regardless of the fail message of the validator

Error: Internal error occurred: fn.render: pkg .:
        pkg.render:
        pipeline.run: error: function failure 

Information

Both Porch and the CLI are on https://github.com/GoogleContainerTools/kpt/tree/208b4c422c85ff6da4cb4c2b9755f0a23a1329c6.

Steps to reproduce the behavior

  1. Create a simple Kpt package using kpt alpha rpkg init

  2. Use kpt alpha rpkg pull to save package to local filesystem

  3. Add a simple StarlarkRun validation resource to the package

apiVersion: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
  name: validate
  annotations:
    config.kubernetes.io/local-config: "true"
source: |-
  fail("Validation always fails")
  1. Update Kptfile to reference StarlarkRun resource
pipeline:
  validators:
  - image: gcr.io/kpt-fn/starlark:v0.4.3
    configPath: validate.yaml
  1. Using kpt fn render the expected error message returns
Package "this-package": 
[RUNNING] "gcr.io/kpt-fn/starlark:v0.4.3"
[FAIL] "gcr.io/kpt-fn/starlark:v0.4.3" in 4.4s
  Results:
    [error]: fail: Validation always fails
  Stderr:
    "failed to evaluate function: error: function failure"
  Exit code: 1
  1. Using kpt alpha rpkg push to push the package to Porch the generic error message is returned
Error: Internal error occurred: fn.render: pkg .:
        pkg.render:
        pipeline.run: error: function failure 

ChristopherFry avatar Jul 30 '22 03:07 ChristopherFry

https://github.com/GoogleContainerTools/kpt/pull/3451 will surface the validation error. Do you mind taking a quick look to see if the format of the returned error works for you?

natasha41575 avatar Aug 09 '22 22:08 natasha41575

Per offline discussion, @droot will be taking over this by surfacing the function results in the API.

natasha41575 avatar Aug 24 '22 20:08 natasha41575