Skip to content

iis: fix collector panic on application pool names containing '#' - #2473

Draft
jkroepke with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-iis-collector-panic
Draft

iis: fix collector panic on application pool names containing '#'#2473
jkroepke with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-iis-collector-panic

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

deduplicateIISNames panicked with slice bounds out of range whenever any IIS application pool name contained a # character, because the function assumed # only appears as a perflib counter suffix (Site_B#2).

Bugs fixed

In deduplicateIISNames (iis.go):

  • strings.Split(name, "#")[0] misidentified "App#Pool" as a duplicate of "App" — replaced with iisCounterBaseName() that validates the suffix is purely numeric via strconv.Atoi
  • Inverted if/else: code that should record a new entry was instead writing to originalIndex (zero value 0), corrupting the first element
  • slices.Delete(counterValues, index, 1) used 1 as the end index rather than index+1, causing the panic
  • Function returned nothing — callers never saw the deduplicated slice; now returns []T
  • Lexicographic sort meant "Site_B#9" incorrectly superseded "Site_B#10"; algorithm now tracks the winning numeric suffix with integer comparison

In iis_w3svc_w3wp.go:

  • strings.Contains(name, "#") skipped metrics for any pool whose name legitimately contains #; replaced with iisCounterBaseName() stripping so only real perflib numeric suffixes are normalised

New helper

// iisCounterBaseName strips a trailing "#<digits>" suffix only.
// "Site_B#2"  → "Site_B"
// "App#Pool"  → "App#Pool"   (non-numeric: unchanged)
// "Pool#Name#2" → "Pool#Name"
func iisCounterBaseName(name string) string { … }

All five callers updated to assign the returned slice. Unit tests added for both iisCounterBaseName and deduplicateIISNames.

Copilot AI and others added 2 commits August 14, 2026 16:46
Co-authored-by: jkroepke <1560587+jkroepke@users.noreply.github.com>
Co-authored-by: jkroepke <1560587+jkroepke@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix IIS collector panic from special characters in application names iis: fix collector panic on application pool names containing '#' Aug 14, 2026
Copilot AI requested a review from jkroepke August 14, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IIS Collector Panic Caused by Certain Characters in Application Names

2 participants