Skip to content

[Bug] apply/assert with an absolute file: path fails with found no test in <path> #2735

Open

Description

@lhp-nemlig

chainsaw version Version

v0.2.15

Description

Disclosure, I did have Claude write this issue since it found the problem for me when i encountered this issue after updating kyverno chainsaw locally. I verified myself that ParseRequestURI works as Claude asserts, in terms of how it parses absolute paths.

On chainsaw v0.2.15 (works on v0.2.14 and earlier), referencing a manifest by an absolute path fails to load it and reports found no test in <path>, even though the file is a valid, non-empty manifest. The same file via a relative path loads fine. This is easy to hit because file: is an expression that resolves to an absolute path at runtime (e.g. file: ($values.gwc) → /tmp/tmp.XXXXXX/gwc.yaml).

Root cause: pkg/runner/operations/helpers.go classifies local-file vs URL with url.ParseRequestURI:

url, err := url.ParseRequestURI(ref)
if err != nil {
    return resource.Load(filepath.Join(basePath, ref), true)   // local
} else {
    return resource.LoadFromURI(url, true)                     // go-getter
}

url.ParseRequestURI interprets its input "only as an absolute URI or an absolute path", so /tmp/x.yaml parses without error and is wrongly routed through LoadFromURI (go-getter) instead of being read off disk — which then fails, hence the misleading found no test for a plainly local file.

Proposed fix: classify by scheme instead, in both fileRefOrResource and fileRefOrCheck (go-getter already provides getter.Detect for this):

if u, err := url.ParseRequestURI(ref); err == nil && u.Scheme != "" {
    return resource.LoadFromURI(u, manifest)   // genuine URL (http/https/file/git/s3/…)
}
if filepath.IsAbs(ref) {
    return resource.Load(ref, manifest)        // absolute local path — don't prepend basePath
}
return resource.Load(filepath.Join(basePath, ref), manifest)

Steps to reproduce

  1. Create a valid manifest at an absolute path, e.g. /tmp/cm.yaml (a ConfigMap).
  2. Run a Test whose step does apply: { file: /tmp/cm.yaml } (or file: ($values.x) bound to that absolute path).

Result: found no test in /tmp/cm.yaml. The same file referenced relatively (file: cm.yaml) applies successfully.

Expected behavior

An absolute path to a local file is loaded from disk (like a relative path is), and the resource is applied. Only refs with an actual URL scheme should go through the go-getter loader.

Screenshots

No response

Logs

Slack discussion

No response

Troubleshooting

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

Activity

  1. LoveChauhan-18 commented on Jun 6, 2026

    @LoveChauhan-18

    Hi, I would like to work on this issue. Can you please assign it to me!

  2. senutpal commented on Jun 6, 2026

    @senutpal

    /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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