fix(dashboards): stop falling back to legacy v1 health score - #2227
fix(dashboards): stop falling back to legacy v1 health score#2227gaspergrom wants to merge 8 commits into
Conversation
Org Lens Projects' health-score mapping fell back to legacy v1 classifyHealthScore() bucketing whenever the warehouse's v2 HEALTH_SCORE_CATEGORY_V2 was null, reintroducing on the Snowflake/BFF side the fallback anti-pattern already banned on the Tinybird side. This made projects like The Linux Kernel Organization show a stale "Fair" label instead of the correct no-score state. hasHealthScore()/mapHealthScore() now require a resolvable v2 category and never fall back to the v1 score. Cache key bumped v3 -> v4 to drop stale cached rows computed under the old fallback logic. LFXV2-3379 Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379 Extends the fix already applied to the Org Lens projects table to the project detail hero, which independently reintroduced the same anti-pattern: mapHealth() fell back to classifyHealthScore(overallScoreV2) whenever the v2 category was null, so a project could show "Unavailable" on the projects table but a stale v1-derived band on its own detail page. mapHealth() now returns the normalized v2 category only, matching the projects table. Also tightens the projects table fix itself: hasHealthScore() no longer requires the legacy HEALTH_OVERALL_SCORE_V2 column to be non-null (the v2 category alone is authoritative), and healthMetrics/metricsState are now gated on the warehouse percentage columns being present, independent of whether the health label's category happens to be null. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: fix-forward round 2 reviewer trio findings on the org-lens health label/metrics fix. hasHealthMetrics() required only one of the four warehouse percentage columns to be present, so roundMetric()'s null-to-0 default fabricated a 0% value for genuinely-unmeasured dimensions on partially-populated rows; it now requires all four. Also bumps the projects and project-detail-hero response cache keys to drop entries computed under the old logic, removes the now-dead HEALTH_OVERALL_SCORE_V2 column from both services' queries, and corrects two stale comments left over from the prior fix. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: round-3 reviewer trio finding. c24b79237/82ba2c837 already removed HEALTH_OVERALL_SCORE_V2 from both services' SQL SELECTs, but left it declared on the shared OrgLensProjectRow interface — a row-interface/SELECT mismatch that would silently resolve to undefined at runtime with no compile error. Removes the dead field and the now-decorative test fixture keys/overrides that referenced it, and retitles the affected tests to what they actually pin. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: full-branch reviewer trio finding (self-serve-code-review, confirmed independently by self-serve-learnings-review). A non-null but unparseable warehouse health_score_category_v2 silently degraded to "unavailable" with no signal, indistinguishable from a project the warehouse hasn't backfilled yet. Adds a WARN log in both services' health mapping when the raw category is present but normalizeHealthScoreCategoryV2 returns null. Also rewrites classifyHealthScore's stale JSDoc, which still claimed to be the shared classifier for both services after this branch removed both of their calls to it in favor of the warehouse-computed category. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
PR SummaryMedium Risk Overview The project-detail hero’s Health breakdown metrics are decoupled from the top-level label: Reviewed by Cursor Bugbot for commit 8ccd768. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Removes legacy health-score fallback logic from Org Lens project summaries and detail heroes.
Changes:
- Uses warehouse v2 categories exclusively.
- Preserves independently available health metrics and partial-score metadata.
- Updates cache versions, warnings, types, and unit tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/shared/src/utils/insights.utils.ts |
Documents v2 category authority. |
packages/shared/src/interfaces/org-lens-projects.interface.ts |
Removes the obsolete raw score field. |
apps/lfx-one/src/server/services/org-lens-projects.service.ts |
Revises list mapping, metrics gating, logging, and caching. |
apps/lfx-one/src/server/services/org-lens-projects.service.spec.ts |
Tests category and metric availability behavior. |
apps/lfx-one/src/server/services/org-lens-project-detail.service.ts |
Revises hero mapping, query, logging, and caching. |
apps/lfx-one/src/server/services/org-lens-project-detail.service.spec.ts |
Tests category-only hero behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
LFXV2-3379: the project-detail hero omitted the health badge entirely when the warehouse has no v2 health category, since healthMeta() returned null and the template's @if has no @else. Render the same "Unavailable" tag the Org Lens projects table already shows for this case instead of hiding the section. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379 - treat an empty-string warehouse category as malformed, not null, so the unrecognized-category WARN log still fires (mapHealth, mapProject) - stop surfacing populated healthMetrics on a row with no health category, so metricsState and healthMetrics agree on what unavailable means - correct two stale doc comments left over from the v1-fallback removal Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8da878d. Configure here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
apps/lfx-one/src/server/services/org-lens-projects.service.ts:422
- This comment now describes behavior that line 536 explicitly prevents: when the normalized category is null,
healthMetricsis always empty even if all percentage columns are populated. Update it to document the category gate so future changes do not restore the inconsistent unavailable-label/metrics combination.
// mapProject fills unselected org-relative metrics with placeholders and maps health/healthMetrics from the
// columns above. metricsState here reflects only the health label (category present → 'health-only'; null →
// 'unavailable') — healthMetrics is gated independently inside mapProject and may still be populated on an
// 'unavailable' row if the warehouse percentage columns are present without a category.
LFXV2-3379: revert the category-gate added in the last round-2 fix commit. It suppressed the metrics breakdown whenever the v2 category was unresolvable, even when the warehouse percentage columns were genuinely populated — the opposite of the no-fallback approach this ticket targets. Insights renders each health sub-score off its own null-ness independent of the top-level label; healthMetrics should do the same. Restores the pre-existing (and still test-covered) behavior. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>

Issue: #2229
Org Lens' projects table and project-detail hero fell back to the legacy v1
classifyHealthScore()bucketing whenever the warehouse's v2HEALTH_SCORE_CATEGORY_V2was null, reintroducing on the Snowflake/BFF side the exact fallback anti-pattern already banned on the Tinybird side. korg (The Linux Kernel Organization) showed a stale "Fair" label instead of the correct no-score state, because its legacyHEALTH_OVERALL_SCORE_V2was still non-null even though the v2 category had gone null.Both services now derive the health label from
normalizeHealthScoreCategoryV2(HEALTH_SCORE_CATEGORY_V2)only, with no fallback to the v1 score.healthMetrics/metricsStateare gated on the four warehouse percentage columns independently of the category, so they don't disappear just because the label happens to be null, and don't fabricate 0% for a dimension the warehouse hasn't measured. Response cache keys were bumped to drop rows computed under the old fallback logic.This branch also fixes a regression independently reintroduced by IN-1262 (merged to
mainasfc7dc2544while this ticket was in flight). That PR'smapHealthScore()fell back toclassifyHealthScore(row.HEALTH_OVERALL_SCORE_V2 ?? 0)whenever the v2 category was null — the same anti-pattern this ticket removes. Rebasing onto the mergedmainsurfaced the conflict and confirmed it; this branch's fix wins, and IN-1262's newhealthMaxScore/healthCoveredCategoryCountfields (used for the partial-Health-Score UI treatment) are preserved unchanged.Commits
stop falling back to legacy v1 health score— the projects-table fixfix legacy v1 health fallback in detail hero too— same fix in the sibling detail-hero servicestop fabricating health data on round-2 review findings— AND-gate the four warehouse percentage columns instead of ORdrop dead HEALTH_OVERALL_SCORE_V2 field— remove the now-unused column from the shared row interfacelog unrecognized v2 health category— WARN log when a non-null category fails to parse, so that case stays distinguishable from "not yet backfilled"Test plan
yarn workspace lfx-one-ui test:server— 104 files / 2744 tests pass, including cases for: v2 category present, v2 category null, v2 category unrecognized (WARN logged), metrics present/partial/absent independent of the category.yarn buildandyarn lint:checkclean.insightsrepo changes — Tinybird's health-label pipeline was already correct; this fix is isolated to lfx-self-serve's Snowflake/BFF mapping layer.