Skip to content

set-namespace exits 0 and reports [PASS] when config is invalid #4547

@aravindtga

Description

@aravindtga

Description

When set-namespace:latest is invoked without a namespace value (empty data.namespace in ConfigMap), the function exits with code 0 and reports [PASS], but simultaneously emits an error-severity result:

  [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest"
  [PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s
  [Results]: [error] v1/ConfigMap/function-input: `data.namespace` should not be empty

Previous behaviour (v0.2.0):

  [FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0"
  error: failed to configure function: input namespace cannot be empty
  Exit code: 1

Steps to reproduce

  cd $(mktemp -d)
  cat > resources.yaml <<EOF
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: nginx-deployment
  spec:
    replicas: 3
  EOF
  kpt fn eval -i ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
  echo "Exit code: $?"
  # Outputs: Exit code: 0

Expected behaviour

The function should exit with code 1 and report [FAIL] when configuration is invalid. Config validation errors should be fatal, not informational.

Metadata

Metadata

Assignees

Labels

area/fn-catalogFunctions CatalogbugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions