Skip to content

Fix critical bugs and extend test coverage#65

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/review-code-propose-fixes
Draft

Fix critical bugs and extend test coverage#65
Copilot wants to merge 3 commits into
mainfrom
copilot/review-code-propose-fixes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

Five correctness bugs found during code review, plus coverage gaps in previously untestable error paths. Coverage: 62.8% → 69.1% (app), 83.3% → 91.7% (metrics).

Bug Fixes

  • unloadProfile — swapped errors.Is arguments (critical)

    // Before — never true; "file not found" early-return never fired
    if _, err := os.Stat(filePath); errors.Is(os.ErrNotExist, err) {
    // After
    if _, err := os.Stat(filePath); errors.Is(err, os.ErrNotExist) {
  • printLoadedProfiles — wrong slice pre-allocation

    // Before — produces len(p) empty-string entries, then appends real names on top
    loadedProfileNames := make([]string, len(p))
    // After
    loadedProfileNames := make([]string, 0, len(p))
  • compareLocalFiles, CopyFile, areProfilesReadableos.Exit(1) in library functions
    All three called os.Exit(1) on recoverable errors (bad read, missing source file, readdir failure), crashing the DaemonSet instead of propagating the error. Replaced with proper return false/nil, fmt.Errorf(...) so callers can log and retry on the next poll cycle.

Coverage Extensions

Enabled by the os.Exit removals:

  • NewConfigFromEnv, newDefaultLogger: 0% → 100%
  • loadNewProfiles: 0% → 24% (empty/missing configmap, missing kernel path, orphan unload)
  • compareLocalFiles, CopyFile, areProfilesReadable error paths
  • metrics.ProfileUpdated: 0% → 100%
  • Additional pollProfiles and /healthz handler coverage

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 13, 2026 17:23
Co-authored-by: tuxerrante <8364469+tuxerrante@users.noreply.github.com>
Co-authored-by: tuxerrante <8364469+tuxerrante@users.noreply.github.com>
Copilot AI changed the title [WIP] Review code and propose fixes with coverage extension Fix critical bugs and extend test coverage Mar 13, 2026
Copilot AI requested a review from tuxerrante March 13, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants