kubernetes/kubernetes · error

filtering incompatible changes: %w

Error message

filtering incompatible changes: %w

What it means

Wrapped error from filterChanges when compiling the allowlist to extract the 'incompatible' (non-allowlisted) changes (main.go:498-500). This is the second filterChanges call (exclude=true). It uses the identical compileAllowlistPatterns path as error 457, so the root cause is the same: a malformed regex in the embedded allowlist.

Source

Thrown at hack/apidiff-changelog/main.go:500

	filtered = trimTrailingEmpty(filtered)

	fmt.Printf("## %s\n", what)
	if len(filtered) == 0 {
		fmt.Println("no changes")
		return "", nil
	}

	preamble, incompatibleLines, compatibleLines := splitApidiffSections(filtered)

	// Filter incompatible changes through the allowlist.
	incompatibleStr := strings.Join(incompatibleLines, "\n")
	tolerated, err := filterChanges(incompatibleStr, false)
	if err != nil {
		return "", fmt.Errorf("filtering tolerated changes: %w", err)
	}
	incompatibleStr, err = filterChanges(incompatibleStr, true)
	if err != nil {
		return "", fmt.Errorf("filtering incompatible changes: %w", err)
	}

	// Print preamble (matches shell's `echo "$changes"`, even when empty, producing a blank line).
	fmt.Println(preamble)
	if incompatibleStr != "" {
		fmt.Println("Incompatible changes:")
		fmt.Print(incompatibleStr)
	}
	if tolerated != "" {
		fmt.Println("Acceptable incompatible changes:")
		fmt.Print(tolerated)
	}
	if len(compatibleLines) > 0 {
		fmt.Println("Compatible changes:")
		fmt.Println(strings.Join(compatibleLines, "\n"))
	}
	fmt.Println()

View on GitHub (pinned to b882c60b40)

Solutions

  1. Same as 457 — fix the invalid regex in api-changes-allowlist.
  2. Run `go test ./hack/apidiff-changelog/...` to catch the regression before it ships.
  3. Add a unit test that asserts compileAllowlistPatterns returns no error, to prevent recurrence.

Example fix

// before: bad regex line in api-changes-allowlist
^*invalid(
// filtering incompatible changes: failed to compile regex "^*invalid(": error parsing regexp...

// after
^[a-z]+: (added|removed)$
// plus a guard test:
func TestAllowlistCompiles(t *testing.T) { if _, err := compileAllowlistPatterns(); err != nil { t.Fatal(err) } }
Defensive patterns

Strategy: validation

Validate before calling

// Same guard as 457 — a single test covers both filterChanges invocations.
func TestAllowlistCompiles(t *testing.T) {
    if _, err := compileAllowlistPatterns(); err != nil { t.Fatalf("allowlist: %v", err) }
}

Type guard

null

Try / catch

incompatibleStr, err = filterChanges(incompatibleStr, true)
if err != nil { return "", fmt.Errorf("filtering incompatible changes: %w", err) }

Prevention

When it happens

Trigger: Same as 457 — compileAllowlistPatterns fails. In practice if error 457 fires it fires first (it is called first at main.go:494), so this branch is only reached if compileAllowlistPatterns becomes non-deterministic, which it is not. Treat both as the same class of defect.

Common situations: Identical to error 457: invalid regex in api-changes-allowlist. In the current code ordering, error 457 will surface before this one; 458 is effectively defensive/unreachable given a single bad line.

Related errors


AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07). Data as JSON: /api/errors/859c7dcbb701595c. Report an issue: GitHub.