Skip to content

fix(scorecard): use consistent thresholds for aggregation cards and drill-down - #5145

Open
dzemanov wants to merge 2 commits into
redhat-developer:mainfrom
dzemanov:fix/scorecard-aggregation-thresholds
Open

dzemanov wants to merge 2 commits into
redhat-developer:mainfrom
dzemanov:fix/scorecard-aggregation-thresholds

Conversation

@dzemanov

@dzemanov dzemanov commented Oct 8, 2026

Copy link
Copy Markdown
Member

Hey, I just made a Pull Request!

Corrects threshold semantics between aggregation cards and their entity drill-down tables.

  • Weighted status score aggregation responses now return the aggregation thresholds used to classify the aggregate score. Consistent with other aggregation responses.
  • Drill-down entity responses now include the underlying metric thresholds used to classify entities in drill-down.
  • Entity-table status colors now use the drill-down response’s metric thresholds, keeping them consistent with the entity scorecard page.

Fixes

Fixes https://redhat.atlassian.net/browse/RHDHBUGS-3918, https://redhat.atlassian.net/browse/RHDHBUGS-3916

Screen.Recording.2026-10-08.at.14.22.00.mov

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

…tusScore

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
@rhdh-gh-app

rhdh-gh-app Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Changed Packages

Package Name Package Path Changeset Bump Current Version
app-legacy workspaces/scorecard/packages/app-legacy none v0.0.0
@red-hat-developer-hub/backstage-plugin-scorecard-backend workspaces/scorecard/plugins/scorecard-backend patch v4.4.2
@red-hat-developer-hub/backstage-plugin-scorecard-common workspaces/scorecard/plugins/scorecard-common patch v4.4.2
@red-hat-developer-hub/backstage-plugin-scorecard workspaces/scorecard/plugins/scorecard patch v4.4.2

@rhdh-qodo-merge

Copy link
Copy Markdown

PR Summary by Qodo

Align scorecard aggregation and drill-down thresholds

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Return aggregation thresholds for weighted scorecards so cards reflect their own classification
 rules.
• Return metric thresholds in drill-down responses and use them to color entity rows.
• Add regression tests and a patch changeset for the affected scorecard packages.
Diagram

graph TD
  AC["Aggregation config"] --> WS["Weighted strategy"] --> CARD["Aggregation card"]
  TR["Threshold resolver"] --> CS["Catalog metric service"] --> DR["Drill-down response"] --> ET["Entities table"] --> ROW["Entity rows"]
  TR --> WS
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Return per-entity resolved colors
  • ➕ Could represent entity-specific threshold annotation overrides accurately.
  • ➖ Requires a larger drill-down contract and per-entity threshold resolution or stored color data.

Recommendation: Use the PR's separate threshold sets: aggregation thresholds classify the aggregate, while shared metric thresholds color drill-down rows. This is a focused contract fix. Per-entity colors are worth considering separately if annotation overrides must also be represented accurately.

Files changed (10) +90 / -6

Bug fix (4) +8 / -2
CatalogMetricService.tsInclude metric thresholds in every drill-down response path +5/-0

Include metric thresholds in every drill-down response path

• Resolves metric-level thresholds and includes them in successful, empty, high-page, and catalog-error responses.

workspaces/scorecard/plugins/scorecard-backend/src/service/CatalogMetricService.ts

WeightedStatusScoreAggregationStrategy.tsReturn weighted aggregate classification thresholds +1/-1

Return weighted aggregate classification thresholds

• Changes the weighted aggregation result to return its headline aggregation thresholds rather than the metric thresholds used for entity status grouping.

workspaces/scorecard/plugins/scorecard-backend/src/service/aggregations/strategies/WeightedStatusScoreAggregationStrategy.ts

Metric.tsExtend the entity drill-down response contract +1/-0

Extend the entity drill-down response contract

• Adds a required metric threshold configuration to EntityMetricDetailResponse for drill-down consumers.

workspaces/scorecard/plugins/scorecard-common/src/types/Metric.ts

EntitiesTable.tsxColor entity rows using drill-down metric thresholds +1/-1

Color entity rows using drill-down metric thresholds

• Passes threshold rules from the entity drill-down response to rows instead of using the aggregate scorecard's thresholds.

workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/EntitiesTable.tsx

Tests (4) +68 / -4
CatalogMetricService.test.tsVerify drill-down returns resolved metric thresholds +10/-0

Verify drill-down returns resolved metric thresholds

• Mocks metric threshold resolution and checks that entity metric details include the resolved rules.

workspaces/scorecard/plugins/scorecard-backend/src/service/CatalogMetricService.test.ts

weightedStatusScoreAggregationStrategy.test.tsCover default and configured weighted aggregation thresholds +35/-1

Cover default and configured weighted aggregation thresholds

• Updates the expected default result and adds a case confirming that configured aggregation thresholds are returned alongside the aggregate display color.

workspaces/scorecard/plugins/scorecard-backend/src/service/aggregations/strategies/weightedStatusScoreAggregationStrategy.test.ts

router.test.tsUpdate drill-down route response fixture +3/-0

Update drill-down route response fixture

• Adds metric thresholds to the mocked entity drill-down response used by route tests.

workspaces/scorecard/plugins/scorecard-backend/src/service/router.test.ts

EntitiesTable.test.tsxVerify entity rows receive drill-down threshold rules +20/-3

Verify entity rows receive drill-down threshold rules

• Adds metric thresholds to the drill-down fixture and checks the rules passed to rendered entity rows.

workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/tests/EntitiesTable.test.tsx

Documentation (2) +14 / -0
legal-lions-join.mdDocument patch releases for three scorecard packages +13/-0

Document patch releases for three scorecard packages

• Adds patch changesets for the backend, common, and frontend packages. Explains the distinct aggregate and entity threshold scopes and notes the limitation for entity-specific overrides.

workspaces/scorecard/.changeset/legal-lions-join.md

report.api.mdRecord thresholds in the published API report +1/-0

Record thresholds in the published API report

• Updates the public API report to show the required threshold configuration on entity metric detail responses.

workspaces/scorecard/plugins/scorecard-common/report.api.md

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.31%. Comparing base (e13aff2) to head (5bb57b3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5145   +/-   ##
=======================================
  Coverage   64.31%   64.31%           
=======================================
  Files        2720     2720           
  Lines      107845   107846    +1     
  Branches    30402    30402           
=======================================
+ Hits        69358    69359    +1     
  Misses      36660    36660           
  Partials     1827     1827           
Flag Coverage Δ *Carryforward flag
adoption-insights 87.11% <ø> (ø) Carriedforward from 49b7d0c
ai-integrations 87.24% <ø> (ø) Carriedforward from 49b7d0c
app-defaults 72.02% <ø> (ø) Carriedforward from 49b7d0c
augment 46.67% <ø> (ø) Carriedforward from 49b7d0c
boost 93.37% <ø> (ø) Carriedforward from 49b7d0c
bulk-import 73.12% <ø> (ø) Carriedforward from 49b7d0c
cost-management 13.56% <ø> (ø) Carriedforward from 49b7d0c
dcm 74.35% <ø> (ø) Carriedforward from 49b7d0c
e2e-adoption-insights 60.00% <ø> (ø) Carriedforward from 49b7d0c
e2e-extensions 62.31% <ø> (ø) Carriedforward from 49b7d0c
e2e-global-header 52.40% <ø> (ø) Carriedforward from 49b7d0c
e2e-homepage 61.11% <ø> (ø) Carriedforward from 49b7d0c
e2e-intelligent-assistant 45.55% <ø> (ø) Carriedforward from 49b7d0c
e2e-orchestrator 49.49% <ø> (ø) Carriedforward from 49b7d0c
e2e-orchestrator-plugin 49.48% <ø> (ø) Carriedforward from 49b7d0c
e2e-quickstart 54.83% <ø> (ø) Carriedforward from 49b7d0c
e2e-scorecard 49.83% <ø> (+0.05%) ⬆️ Carriedforward from 49b7d0c
e2e-theme 16.43% <ø> (ø) Carriedforward from 49b7d0c
extensions 58.30% <ø> (ø) Carriedforward from 49b7d0c
global-floating-action-button 71.18% <ø> (ø) Carriedforward from 49b7d0c
global-header 69.10% <ø> (ø) Carriedforward from 49b7d0c
homepage 56.73% <ø> (ø) Carriedforward from 49b7d0c
install-dynamic-plugins 84.02% <ø> (ø) Carriedforward from 49b7d0c
intelligent-assistant 78.62% <ø> (ø) Carriedforward from 49b7d0c
konflux 91.98% <ø> (ø) Carriedforward from 49b7d0c
lightspeed 69.02% <ø> (ø) Carriedforward from 49b7d0c
mcp-integrations 84.46% <ø> (ø) Carriedforward from 49b7d0c
orchestrator 77.69% <ø> (ø) Carriedforward from 49b7d0c
quickstart 65.83% <ø> (ø) Carriedforward from 49b7d0c
sandbox 79.56% <ø> (ø) Carriedforward from 49b7d0c
scorecard 90.53% <100.00%> (+<0.01%) ⬆️
theme 87.44% <ø> (ø) Carriedforward from 49b7d0c
translations 7.91% <ø> (ø) Carriedforward from 49b7d0c
x2a 79.51% <ø> (ø) Carriedforward from 49b7d0c

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e13aff2...5bb57b3. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rhdh-qodo-merge

rhdh-qodo-merge Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Demo rows lose their status colors ✓ Resolved
Description
EntitiesTable now reads status colors exclusively from aggregatedScorecardEntities.thresholds,
but the shared mock entity response does not include that field. Both development API
implementations return that fixture, so their drill-down rows fall back to the error-state color
even when a row’s status is success or warning.
Code

workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/EntitiesTable.tsx[105]

+  const thresholdRules = aggregatedScorecardEntities?.thresholds?.rules ?? [];
Relevance

●●● Strong

Accepted correctness issue: development fixtures omit newly required thresholds, causing incorrect
error colors in drill-down rows.

PR-#4685
PR-#4395

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The shared fixture has entities with success and warning statuses but no thresholds property. Both
development API implementations return it; the changed table reads its missing thresholds as an
empty rule list, and EntitiesRow uses the error-state color when no rule matches.

workspaces/scorecard/plugins/scorecard/fixtures/aggregatedScorecardEntitiesData.ts[23-64]
workspaces/scorecard/plugins/scorecard/dev/mocks.ts[253-261]
workspaces/scorecard/plugins/scorecard/dev/legacy.tsx[192-200]
workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/EntitiesTable.tsx[105-105]
workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/EntitiesRow.tsx[52-55]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The development drill-down fixture omits the newly required thresholds, causing its entity rows to use the error-state fallback color.
## Fix Focus Areas
- workspaces/scorecard/plugins/scorecard/__fixtures__/aggregatedScorecardEntitiesData.ts[23-30]
- workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/EntitiesTable/EntitiesTable.tsx[105-105]
## Recommended Fix
Add the metric-level threshold rules used by the mock entity statuses to the shared drill-down response fixture, and verify that success and warning rows receive their corresponding colors.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
⚠️ Tickets: not configured — ticket URL found in PR but could not be fetched — check ticket provider credentials
✅ Compliance rules (platform): 9 rules
✅ Cross-repo context — repo relationships
  Explored: repo: redhat-developer/rhdh (sha: e2f0f51d) — View relationship
Review mode: Auto: ⚖️ Balanced: Behavioral API and threshold classification changes warrant a careful single-pass review.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@rhdh-qodo-merge

Copy link
Copy Markdown

Important

The /generate_labels command by Qodo is sunsetting on the 1st of October 2026 and will no longer be available. We recommend switching to the latest Qodo review capabilities. Learn more

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant