kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.7k stars 2.22k forks source link

errors accumulating remote directories are not reported in certain situations #5692

Closed colinodell closed 1 month ago

colinodell commented 1 month ago

What happened?

Under these conditions ...

  1. A resource is defined with an https git reference
  2. The web server uses a catch-all authentication challenge web page
  3. The resource is successfully retrieved as a base but directory accumulation fails for any reason

... the error from the third step is not reported.

The first two conditions are identical to #5540, so I'll quote the relevant bits here:

Since a catch-all authentication challenge web page is in place, the attempt to accumulate the resource as a file receives a 200 response. As a result, fileloader.httpClientGetContent() does not do a check of the path to see if it's a git repo. That means FromFile processes the HTML of the web page, and properly returns a YAML parse error.

accumulateResources then attempts to process the resource as a git reference.

Unlike #5540, the remote repository is successfully cloned, so the code proceeds to call kt.accumulateDirectory(). If that accumulation fails for any reason, a decision is made how to report the failure. But if errF (from earlier in the method) was a malformed YAML error, the error from kt.accumulateDirectory() is dropped:

https://github.com/kubernetes-sigs/kustomize/blob/e244b83844cd5e1d114b731713c7f437e510c023/api/internal/target/kusttarget.go#L451-L457

The result is that the user does not receive any information about why kustomize failed to accumulate the directory. They instead see an error like:

MalformedYAMLError: yaml: line 3: mapping values are not allowed in this context in File: https://git.example.com/some/repo.git//some/path?ref=main

What did you expect to happen?

I expect to see the error from accumulating the directory - something like:

accumulateDirectory: "recursed accumulation of path '/private/var/folders/17/0lz0_dxs2x7b9pf358vjppp80000gq/T/kustomize-1978055679/some/path': error unmarshaling JSON: while decoding JSON: json: unknown field \"whatever\""

How can we reproduce it (as minimally and precisely as possible)?

I unfortunately don't have a fully working reproducer I can share :-/

Expected output

No response

Actual output

No response

Kustomize version

v5.4.1

Operating system

None

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.