Skip to content

Incomplete Error Handling in Issue Label Changes #12

@pedrogaudencio

Description

@pedrogaudencio

Problem

Location: modules/actions/workflows.go (lines 377-398)

actions := []string{}
switch issuePayload.Action {
case api.HookIssueLabelUpdated:
    if len(issuePayload.Changes.AddedLabels) > 0 {
        actions = append(actions, "labeled")
    }
    if len(issuePayload.Changes.RemovedLabels) > 0 {
        actions = append(actions, "unlabeled")
    }

Issue: If both AddedLabels and RemovedLabels are empty (which could happen with a malformed webhook payload), actions will be empty and the subsequent loop will not match anything, potentially causing unexpected behavior.

Solution

Fix: Add validation:

actions := []string{}
switch issuePayload.Action {
case api.HookIssueLabelUpdated:
    if len(issuePayload.Changes.AddedLabels) > 0 {
        actions = append(actions, "labeled")
    }
    if len(issuePayload.Changes.RemovedLabels) > 0 {
        actions = append(actions, "unlabeled")
    }
    // If no labels were added or removed, this is invalid
    if len(actions) == 0 {
        log.Warn("HookIssueLabelUpdated action without added or removed labels")
        return false
    }

Metadata

Metadata

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