Skip to content

Missing return statement after error #244

Closed
@dholbach

Description

@dholbach

From Ada Logics

In the Image-automation reconciler an issue is present where the code continues after an error occurs, leading to undefined behaviour:

// Here's where it gets constrained. If there's no push branch
// given, then the checkout ref must include a branch, and
// that can be used.
if ref == nil || ref.Branch == "" {
return failWithError(fmt.Errorf("Push branch not given explicitly, and cannot be inferred from .spec.git.checkout.ref or GitRepository .spec.ref"))
}
pushBranch = ref.Branch
tracelog.Info("using push branch from $ref.branch", "branch", pushBranch)

The problem is that the failWithError branch does not itself return from the reconcile function and the code should instead be return failWithError

Recommendation

Change the code to return failWithError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions