Skip to content

[Bug] scenario name not exposed in bindings #2614

@heydonovan

Description

@heydonovan

chainsaw version Version

v0.2.14

Description

The JSON schema shows that scenarios can be given a name:

$ curl -s "https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json" | jq '.properties.spec.properties.scenarios.items.properties.name'
{
  "description": "Scenario name.",
  "type": [
    "string",
    "null"
  ]
}

For now, I've just been duplicating each scenario as a different test:

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: dev
spec:
  namespaceTemplate:
    metadata:
      name: (join('-', ['chainsaw', $values.sha, 'dev']))
  bindings:
      - name: env
        value: dev
---
metadata:
  name: production
spec:
  namespaceTemplate:
    metadata:
      name: (join('-', ['chainsaw', $values.sha, 'production']))
  bindings:
    - name: env
      value: production

Steps to reproduce

If I define a scenario name, chainsaw will throw an error:

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: scenario-name-test
spec:
  scenarios:
    - name: my-custom-scenario
      bindings:
        - name: env
          value: dev
  steps:
    - try:
        - script:
            env:
              - name: TEST_INFO
                value: (to_string($test))
            content: |
              echo "Available in \$test binding:"
              echo "$TEST_INFO"

$ chainsaw test
Version: 0.2.14
Loading default configuration...
- Using test file: chainsaw-test
...
Loading tests...
Error: failed to parse document (spec.scenarios[0].name: Invalid value: value provided for unknown field)

If I remove name, I'm not seeing the field exposed either:

=== COMMAND
/bin/sh -c echo "Available in \$test binding:"
echo "$TEST_INFO"
=== STDOUT
Available in $test binding:
{"Id":1,"ScenarioId":1,"Metadata":{"name":"scenario-name-test"}}

Expected behavior

The scenario name should be accessible in the $test binding ($test.ScenarioName or similar)

Screenshots

No response

Logs

Here is my current version:


$ chainsaw version
Version: 0.2.14
Time: 2025-12-08T11:22:44Z
Git commit ID: 56496eccfcf62324aeadff8ad79ffcf81f6d1959

Slack discussion

No response

Troubleshooting

  • I have searched other issues in this repository and mine is not recorded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions