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

Stop errorfactory from creating errors with nil causes #451

Merged
merged 4 commits into from
Sep 3, 2024

Conversation

jgibson
Copy link
Contributor

@jgibson jgibson commented Aug 29, 2024

Q A
Bug fix? yes
New feature? no
API breaks? no
Deprecations? no
Related tickets
License Apache 2.0

What's in this PR?

Currently when the errorfactory is invoked with a nil error the errorfactory will produce an error that has nil error field. This PR will create a new underlying error when presented with a nil error.

Why?

Some consumers of the error assume that the error has been populated and when they access the field it triggers a panic. In particular logging code like this in nificluster_controller.go fails:

r.Log.Info("Nodes unreachable, may still be starting up", zap.String("reason", err.Error()))

Some error producers need to report errors even the underlying failure doesn't produce an error itself. For example in client.go:

clusterEntity, err := n.DescribeCluster()
if err != nil || clusterEntity == nil || clusterEntity.Cluster == nil {
	err = errorfactory.New(errorfactory.NodesUnreachable{}, err, fmt.Sprintf("could not connect to nifi nodes: %s", n.opts.NifiURI))
	return err
}

Additional Context

This failure made it more difficult to diagnose some underlying connectivity and configuration issues that I encountered when I moved on from an insecure cluster to an SSL-secured one.

Checklist

  • Implementation tested
  • Append changelog with changes

Copy link
Contributor

@juldrixx juldrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add your change in the CHANGELOG?

@jgibson
Copy link
Contributor Author

jgibson commented Sep 3, 2024

OK, I've updated the CHANGELOG. It seemed presumptuous to update the CHANGELOG before a maintainer accepted it.

@juldrixx juldrixx merged commit 832ffab into konpyutaika:master Sep 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants