Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not swallow parsing errors #5722

Merged
merged 1 commit into from
Apr 24, 2021

Conversation

briandealwis
Copy link
Member

Description
Seen in #5719, where Skaffold's error message doesn't provide any helpful detail on the source of the error:

parsing skaffold config: failed to apply profiles to config "cryptobot" defined in file "/home/gitlab-runner/builds/ZqTVFjA1/0/high-school-prod/cryptobot/skaffold.yaml". There's an issue with one of the profiles defined in config "cryptobot" in file "/home/gitlab-runner/builds/ZqTVFjA1/0/high-school-prod/cryptobot/skaffold.yaml"; refer to the documentation on how to author valid profiles: https://skaffold.dev/docs/environment/profiles/.

"What is the issue!?" I cried in vain.

It turns out that we're swallowing the errors when generating our actionable error wrappers.

This PR exposes these errors.

As a result, errors like:

$ skaffold build -p stage 
parsing skaffold config: error parsing skaffold configuration file

now become:

$ skaffold build -p stage
parsing skaffold config: error parsing skaffold configuration file: parsing api version: yaml: line 13: did not find expected key

Note: I had thought about changing ErrDef.Error():

func (e ErrDef) Error() string {
if s := concatSuggestions(e.Suggestions()); s != "" {
return fmt.Sprintf("%s. %s", e.ae.Message, concatSuggestions(e.Suggestions()))
}
return e.ae.Message

Except most other actionable error definitions use fmt.Sprintf("<message>: %v", err) to inline the error object.

@briandealwis briandealwis requested a review from a team as a code owner April 24, 2021 02:27
@google-cla google-cla bot added the cla: yes label Apr 24, 2021
@codecov
Copy link

codecov bot commented Apr 24, 2021

Codecov Report

Merging #5722 (ccaa545) into master (21debe2) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5722      +/-   ##
==========================================
+ Coverage   70.74%   70.81%   +0.06%     
==========================================
  Files         421      421              
  Lines       16037    16043       +6     
==========================================
+ Hits        11346    11361      +15     
+ Misses       3858     3847      -11     
- Partials      833      835       +2     
Impacted Files Coverage Δ
pkg/skaffold/schema/errors/errors.go 100.00% <100.00%> (ø)
pkg/skaffold/build/local/local.go 61.36% <0.00%> (-6.82%) ⬇️
pkg/skaffold/build/cluster/cluster.go 22.85% <0.00%> (-2.86%) ⬇️
pkg/skaffold/build/gcb/cloud_build.go 0.00% <0.00%> (-0.71%) ⬇️
cmd/skaffold/app/cmd/flags.go 89.02% <0.00%> (ø)
pkg/skaffold/runner/runner.go 0.00% <0.00%> (ø)
pkg/skaffold/config/options.go 100.00% <0.00%> (ø)
pkg/skaffold/runner/build_deploy.go 69.23% <0.00%> (ø)
pkg/skaffold/runner/runcontext/context.go 84.74% <0.00%> (+0.13%) ⬆️
...affold/kubernetes/portforward/kubectl_forwarder.go 69.71% <0.00%> (+2.11%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21debe2...ccaa545. Read the comment docs.

@briandealwis briandealwis merged commit 5e2d86a into GoogleContainerTools:master Apr 24, 2021
@briandealwis briandealwis deleted the errmsgs branch April 24, 2021 03:05
@gsquared94
Copy link
Contributor

Note: I had thought about changing ErrDef.Error()

my bad, I thought that's what it did 🤦🏽‍♂️

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

Successfully merging this pull request may close these issues.

2 participants