Skip to content

🌱 Add linter to show nil panic.#1960

Merged
guettli merged 7 commits intov1.1.xfrom
tg/avoid-nil-error-panic
Apr 18, 2026
Merged

🌱 Add linter to show nil panic.#1960
guettli merged 7 commits intov1.1.xfrom
tg/avoid-nil-error-panic

Conversation

@guettli
Copy link
Copy Markdown
Collaborator

@guettli guettli commented Apr 14, 2026

It makes sense to merge #1958 first, because currently unit-tests fail on v1.1.x.


The code contained an obvious nil panic on err.Error()

		err = action.Error()
		if err != nil {
			err = fmt.Errorf("action %+v failed (wait for rescue enabled): %w", action, err)
			s.scope.Error(err, "")
			err := s.scope.SetErrorAndRemediate(ctx, err.Error())
			if err != nil {
				return reconcile.Result{}, err
			}
			conditions.MarkFalse(hm, infrav1.ServerProvisionedCondition,
				"EnablingRescueActionFailed", clusterv1.ConditionSeverityWarning,
				"%s", err.Error())
			return reconcile.Result{}, nil
		}

No linter complained up to now.

Govet nilness does detect that now.

The code contained an obvious nil panic on err.Error()

```go
		err = action.Error()
		if err != nil {
			err = fmt.Errorf("action %+v failed (wait for rescue enabled): %w", action, err)
			s.scope.Error(err, "")
			err := s.scope.SetErrorAndRemediate(ctx, err.Error())
			if err != nil {
				return reconcile.Result{}, err
			}
			conditions.MarkFalse(hm, infrav1.ServerProvisionedCondition,
				"EnablingRescueActionFailed", clusterv1.ConditionSeverityWarning,
				"%s", err.Error())
			return reconcile.Result{}, nil
		}
```

No linter complained up to now.

Govet nilness does detect that now.
@github-actions github-actions Bot added the size/XS Denotes a PR that changes 0-20 lines, ignoring generated files. label Apr 14, 2026
@github-actions github-actions Bot added size/S Denotes a PR that changes 20-50 lines, ignoring generated files. area/test Changes made in the test directory area/code Changes made in the code directory area/api Changes made in the api directory and removed size/XS Denotes a PR that changes 0-20 lines, ignoring generated files. labels Apr 14, 2026
@github-actions github-actions Bot added size/XS Denotes a PR that changes 0-20 lines, ignoring generated files. and removed size/S Denotes a PR that changes 20-50 lines, ignoring generated files. labels Apr 14, 2026
@guettli guettli requested a review from janiskemper April 14, 2026 15:09
@guettli guettli marked this pull request as ready for review April 18, 2026 08:32
@guettli guettli merged commit a5b5610 into v1.1.x Apr 18, 2026
12 checks passed
@guettli guettli deleted the tg/avoid-nil-error-panic branch April 18, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Changes made in the api directory area/code Changes made in the code directory area/test Changes made in the test directory size/XS Denotes a PR that changes 0-20 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants