Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.
This repository was archived by the owner on Feb 4, 2026. It is now read-only.

Method should never return explicit error type (only error interface) #468

Description

@liran-funaro

Assigning explicit error type (e.g., *ierrors.NotLeaderError) to an interface variable (e.g. var err error) will result in nil check to return false even if we assign a nil to it.
See https://go.dev/doc/faq#nil_error and https://go.dev/play/p/8HUKlSDPvCT

The following needs to change in bcdb/db.go:

DB

type DB interface {
	IsLeader() *ierrors.NotLeaderError
}

should be

type DB interface {
	IsLeader() error
}

TxProcessor

type TxProcessor interface {
	IsLeader() *ierrors.NotLeaderError
}

should be

type TxProcessor interface {
	IsLeader() error
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions