Skip to content

Fix/1114 health summary failure aliases#1184

Merged
muddlebee merged 4 commits intoTracer-Cloud:mainfrom
AniketR10:fix/1114-health-summary-failure-aliases
May 1, 2026
Merged

Fix/1114 health summary failure aliases#1184
muddlebee merged 4 commits intoTracer-Cloud:mainfrom
AniketR10:fix/1114-health-summary-failure-aliases

Conversation

@AniketR10
Copy link
Copy Markdown
Contributor

@AniketR10 AniketR10 commented May 1, 2026

Fixed #1114

Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

The bug is a consistency issue between two functions that both normalize the same input but disagree on the rules. status_badge() already had a complete alias table for failure-like statuses (failed, fail, error, unhealthy); _summary_counts() only matched the canonical bucket name. The fix is to make both share the same normalization shape.

I considered three approaches:

  1. Inline a second if/elif ladder inside _summary_counts() — would work, but duplicates the alias list from status_badge() and drifts the moment one of them adds a new alias.
  2. Have _summary_counts() call status_badge() and key off .plain — couples a counting function to a Rich Text rendering function, which feels backwards: rendering should depend on classification, not the other way around.
  3. (Chosen) Pull the alias→bucket relationship into a small module-level _STATUS_BUCKETS dict and let _summary_counts() look up. It's the smallest change, keeps both functions independent of each other, and makes the alias set obvious to a reader.

Key pieces:

  • _STATUS_BUCKETS: maps every recognized status string (already lowercased/stripped at the call site) to its canonical bucket. Aliases like pass/ok/healthy collapse to passed; fail/error/unhealthy collapse to failed.
  • _summary_counts(): unchanged signature and return shape. The body is now a single dict.get(status, "other") lookup followed by an increment, so unknown statuses still fall through to other exactly as before.

Edge cases covered by the new tests:

  • Mixed casing (FAILED) - already handled by the existing .strip().lower(), asserted explicitly.
  • Empty string - falls through to other.
  • Statuses the badge maps to WARN (warn, degraded) stay as other because the JSON shape doesn't have a warn bucket and the issue scopes this fix to failure-state alignment.

Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 1, 2026

Greptile Summary

This PR fixes a long-standing inconsistency where _summary_counts() only matched exact canonical bucket names (passed, missing, failed) while status_badge() accepted a broader set of aliases — causing statuses like error or unhealthy to silently fall into other in the JSON summary. The fix extracts a shared _STATUS_BUCKETS lookup dict so both functions use the same normalization rules, backed by three new focused tests.

  • P0 blocker: docs/daily-updates/2026-04-30.mdx contains unresolved Git merge conflict markers (<<<<<<</=======/>>>>>>>) that will break any MDX documentation build.

Confidence Score: 4/5

Not safe to merge until the unresolved merge conflict in the docs file is resolved.

The core code change in health_view.py is correct and well-tested. The only blocker is the unresolved Git conflict markers in docs/daily-updates/2026-04-30.mdx, which would break the documentation build. Once that file is fixed, this PR is ready to merge.

docs/daily-updates/2026-04-30.mdx — unresolved merge conflict must be resolved before merging.

Important Files Changed

Filename Overview
app/cli/support/health_view.py Introduces _STATUS_BUCKETS dict to normalize failure/pass aliases in _summary_counts(), fixing the consistency gap with status_badge(). Logic is correct and clean.
tests/cli/test_health_view.py Adds three targeted new tests for alias normalization (failure aliases, passed aliases, unknown/other fallthrough) and updates the existing test_summary_counts to reflect the corrected expected counts.
docs/daily-updates/2026-04-30.mdx Contains unresolved Git merge conflict markers on lines 57–61 that will break any MDX build or documentation parser.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["status string (raw)"] --> B[".strip().lower()"]
    B --> C{"_STATUS_BUCKETS.get(status, 'other')"}
    C -->|"passed / pass / ok / healthy"| D["bucket = 'passed'"]
    C -->|"missing"| E["bucket = 'missing'"]
    C -->|"failed / fail / error / unhealthy"| F["bucket = 'failed'"]
    C -->|"warn / degraded / unknown / empty / …"| G["bucket = 'other'"]
    D --> H["counts[bucket] += 1"]
    E --> H
    F --> H
    G --> H
    H --> I["return counts dict"]
Loading

Reviews (1): Last reviewed commit: "fix(cli): align health summary counts wi..." | Re-trigger Greptile

Comment thread docs/daily-updates/2026-04-30.mdx Outdated
Comment on lines +57 to +61
<<<<<<< HEAD
- Fallback summary used: `yes`
=======
- Fallback summary used: `no`
>>>>>>> ec13f462 (docs(daily-update): archive 2026-04-30)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Unresolved merge conflict

This file contains raw Git conflict markers (<<<<<<<, =======, >>>>>>>). Any MDX parser or documentation build pipeline will fail or render the conflict markers literally. One of the two values — yes or no — needs to be chosen and the conflict markers removed before this file can be merged.

The archive committed in bff812a left raw <<<<<<< / ======= / >>>>>>>
markers in the Generation metadata block, which would break MDX rendering.
Resolved to `Fallback summary used: no` to match the original ec13f46
generation and the dominant value across the daily-updates folder.
@muddlebee muddlebee merged commit b235a02 into Tracer-Cloud:main May 1, 2026
10 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🍕 @AniketR10's PR: crispy edges, no unnecessary toppings, delivered on time. Understood the assignment. 🔥


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

@AniketR10 AniketR10 deleted the fix/1114-health-summary-failure-aliases branch May 1, 2026 17:23
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.

Align health summary counts with status badge behavior

2 participants