Skip to content

wolfictl lint doesn't print out actual error #1499

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

Open
Dentrax opened this issue Mar 17, 2025 · 1 comment · May be fixed by #1500
Open

wolfictl lint doesn't print out actual error #1499

Dentrax opened this issue Mar 17, 2025 · 1 comment · May be fixed by #1500
Labels
bug Something isn't working needs-triage applied to all new customer/user issues. Removed after triage occurs.

Comments

@Dentrax
Copy link
Member

Dentrax commented Mar 17, 2025

Description

It just prints the linting failed error, but we can't see the actual error unless we pass the --log-level debug flag:

wolfictl lint .
2025/03/17 14:14:35 ERRO linting failed

wolfictl lint --log-level error
2025/03/17 14:14:35 ERRO linting failed

Action doesn't have this flag: https://github.com/wolfi-dev/actions/blob/117317a80d8d1e32227a90838672b34f04fa65b3/wolfictl-lint/action.yaml#L27

@Dentrax Dentrax added bug Something isn't working needs-triage applied to all new customer/user issues. Removed after triage occurs. labels Mar 17, 2025
@maxgio92
Copy link
Member

maxgio92 commented Mar 17, 2025

I don't know why we're wrapping errors and print them as info, maybe I'm missing something.

But this seems more logic to me:

diff --git a/pkg/lint/linter.go b/pkg/lint/linter.go
index 7ce6d6f..eb8fec6 100644
--- a/pkg/lint/linter.go
+++ b/pkg/lint/linter.go
@@ -111,16 +111,22 @@ func (l *Linter) Lint(ctx context.Context, minSeverity Severity) (Result, error)
 // Print prints the result to stdout.
 func (l *Linter) Print(ctx context.Context, result Result) {
 	log := clog.FromContext(ctx)
-	foundAny := false
+	if !result.HasErrors() {
+		log.Infof("No linting issues found!")
+		return
+	}
 	for _, res := range result {
-		if res.Errors.WrapErrors() != nil {
-			foundAny = true
-			log.Infof("Package: %s: %s", res.File, res.Errors.WrapErrors())
+		for _, v := range res.Errors {
+			switch v.Rule.Severity.Value {
+			case SeverityErrorLevel:
+				log.Errorf("Package: %s: %s", res.File, v.Error)
+			case SeverityWarningLevel:
+				log.Warnf("Package: %s: %s", res.File, v.Error)
+			case SeverityInfoLevel:
+				log.Infof("Package: %s: %s", res.File, v.Error)
+			}
 		}
 	}
-	if !foundAny {
-		log.Infof("No linting issues found!")
-	}
 }
 
 // PrintRules prints the rules to stdout.

as it wouldn't skip errors and warning that right now need to enable the debug log level to be printed, but that increases the verbosity more than needed as it would include also all the other debug logs. It sounds not logic to me, to enable debug mode to print error failed rules of error severity - which indeed, make the lint command to exit 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage applied to all new customer/user issues. Removed after triage occurs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants