Skip to content

fix: return v2 health score total in public project insights api - #2117

Merged
gaspergrom merged 4 commits into
mainfrom
fix/IN-1212-public-api-v2-health-score
Aug 26, 2026
Merged

fix: return v2 health score total in public project insights api#2117
gaspergrom merged 4 commits into
mainfrom
fix/IN-1212-public-api-v2-health-score

Conversation

@gaspergrom

Copy link
Copy Markdown
Collaborator

Summary

  • /api/project/{slug}/insights (the public, unauthenticated API documented in frontend/docs/openapi.json that CNCF and other LF web properties consume) still returned the legacy v1 healthScore field verbatim from the project_insights Tinybird pipe, even though that same pipe already computes healthScoreV2.
  • The internal SSR route (health-score-v2.get.ts) was already updated to serve v2, so Insights' own UI shows v2 scores while the public API — and everything that reads it, including cncf.io/projects/* — still shows v1. This is the gap Joana flagged in IN-1212 comment 118228 (Argo showing v1 on cncf.io vs v2 on insights.linuxfoundation.org).
  • Fix: the public endpoint now returns healthScoreV2 as the healthScore field value (falling back to the legacy v1 value if v2 hasn't been computed yet for a given project), while every other field in the response is untouched — matching AC Setup pinia #3 on IN-1212 ("system returns v2 total score in public API responses; all other metrics remain unchanged from previous responses").

Test plan

  • pnpm tsc-check — passes
  • pnpm lint:fix — no new warnings/errors introduced
  • Manually verify /api/project/argo/insights in staging returns the v2 total score
  • Confirm with Joana whether CNCF also needs the new v2 quality label surfaced, or coordination before they adopt the new score range/labels (open question from her comment, not addressed by this fix)

JIRA: IN-1212

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI balanced review requested due to automatic review settings August 26, 2026 09:06

Copilot AI left a comment

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.

Pull request overview

Updates the public project insights API to expose the v2 health score while preserving compatibility.

Changes:

  • Returns healthScoreV2 as healthScore.
  • Falls back to the legacy score when v2 is unavailable.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI review requested due to automatic review settings August 26, 2026 09:12

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread frontend/server/api/project/[slug]/insights.get.ts
@gaspergrom gaspergrom self-assigned this Aug 26, 2026
@gaspergrom
gaspergrom requested a review from joanagmaia August 26, 2026 09:18
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI review requested due to automatic review settings August 26, 2026 10:12
…-1212

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

frontend/server/api/project/[slug]/insights.get.ts:45

  • healthScoreV2 is nullable, so this intentionally permits healthScore: null, but the public OpenAPI contract still marks healthScore as a required, non-null number. Update that schema (and any public response type) to allow null; otherwise generated clients and response validators will reject valid responses for projects without a v2 score.
      healthScore: project.healthScoreV2,

Comment on lines +257 to +269
"healthLabel": {
"type": "string",
"nullable": true,
"enum": [
"excellent",
"healthy",
"fair",
"concerning",
"critical",
null
],
"description": "Qualitative band for healthScore. Null if not yet computed for this project."
},
Comment on lines +257 to +268
"healthLabel": {
"type": "string",
"nullable": true,
"enum": [
"excellent",
"healthy",
"fair",
"concerning",
"critical",
null
],
"description": "Qualitative band for healthScore. Null if not yet computed for this project."
Copilot AI review requested due to automatic review settings August 26, 2026 10:14

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

frontend/docs/openapi.json:259

  • This document declares OpenAPI 3.1, where nullable is no longer the way to extend a type with null. With type: "string", the null enum member still fails type validation, so the schema contradicts the description. Express nullability with a string | null union instead.
            "type": "string",
            "nullable": true,


return {
...project,
healthScore: project.healthScoreV2,
return {
...project,
healthScore: project.healthScoreV2,
healthLabel: project.healthLabel,
joanagmaia added a commit to joanagmaia/cncf.io that referenced this pull request Aug 26, 2026
LFX Insights has released a new 5-tier Health Score system that
replaces the previous Excellent/Healthy/Stable/Unsteady/Critical bands
with recalibrated thresholds and renamed labels.

New bands:
  85–100  Excellent
  70–84   Healthy
  50–69   Fair
  30–49   Concerning
  0–29    Critical

Changes:
- Extract threshold logic from project-single.php into a new
  LF_Utils::get_health_band() helper to eliminate the duplicated
  if/elseif ladders (icon + label were separate blocks).
- Update thresholds from > comparisons to >= to match the inclusive
  band boundaries.
- Rename stable.svg → fair.svg and unsteady.svg → concerning.svg so
  icon filenames match the labels they represent.

Coordinated with Insights public API release:
linuxfoundation/insights#2117

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
@gaspergrom
gaspergrom merged commit f9ad353 into main Aug 26, 2026
11 checks passed
@gaspergrom
gaspergrom deleted the fix/IN-1212-public-api-v2-health-score branch August 26, 2026 10:32
cjyabraham pushed a commit to cncf/cncf.io that referenced this pull request Aug 27, 2026
LFX Insights has released a new 5-tier Health Score system that
replaces the previous Excellent/Healthy/Stable/Unsteady/Critical bands
with recalibrated thresholds and renamed labels.

New bands:
  85–100  Excellent
  70–84   Healthy
  50–69   Fair
  30–49   Concerning
  0–29    Critical

Changes:
- Extract threshold logic from project-single.php into a new
  LF_Utils::get_health_band() helper to eliminate the duplicated
  if/elseif ladders (icon + label were separate blocks).
- Update thresholds from > comparisons to >= to match the inclusive
  band boundaries.
- Rename stable.svg → fair.svg and unsteady.svg → concerning.svg so
  icon filenames match the labels they represent.

Coordinated with Insights public API release:
linuxfoundation/insights#2117

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

3 participants