Skip to content

[business-logic] breaking_change_check truncation always reports 0 more changes — agent misses unreported breaking changes #84

Description

@topcheer

Bug: breaking_change_check.go truncation always shows "...and 0 more"

File

internal/agent/breaking_change_check.go lines 92-96

Problem

The truncation logic for breaking change warnings always reports "0 more" breaking changes regardless of how many were actually truncated:

if len(warnings) > 2 {
    warnings = warnings[:2]  // ← len(warnings) is now 2
    warnings = append(warnings, fmt.Sprintf("...and %d more breaking change(s)", len(warnings)-2))
    //                                                                  ^^^^^^^^^^^^^^^^ = 2-2 = 0, ALWAYS
}

Root Cause

warnings = warnings[:2] truncates the slice to length 2 BEFORE computing len(warnings)-2. So the count is always 2-2=0.

Impact

When 3+ exported symbols are modified simultaneously (common in refactoring), the agent sees only 2 warnings and is told there are "0 more" — misleading it into thinking all breaking changes are covered. This causes the agent to miss updating callers of the remaining changed symbols.

Comparison with correct pattern

close_error_check.go (lines 82-86) implements the same truncation correctly:

if len(warnings) > maxCloseErrWarnings {
    truncMsg := fmt.Sprintf("... and %d more ignored Close() error warning(s)", len(warnings)-maxCloseErrWarnings)
    warnings = warnings[:maxCloseErrWarnings]
    warnings = append(warnings, truncMsg)
}

Here the count is computed BEFORE truncation, which is correct.

Fix

if len(warnings) > 2 {
    moreCount := len(warnings) - 2  // compute before truncation
    warnings = warnings[:2]
    warnings = append(warnings, fmt.Sprintf("...and %d more breaking change(s)", moreCount))
}

Severity

Medium — functional but misleading. No crash, but causes the agent to miss breaking changes during refactoring.

Verification

Independently verified by sub-agent with a constructed test case showing 5 warnings produce "...and 0 more" instead of "...and 3 more".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions