Skip to content

fix(scorecards): correct check output units and related properties - #60

Open
colmcahalane-toast wants to merge 2 commits into
get-dx:mainfrom
colmcahalane-toast:fix/scorecard-check-output-and-related-properties
Open

fix(scorecards): correct check output units and related properties#60
colmcahalane-toast wants to merge 2 commits into
get-dx:mainfrom
colmcahalane-toast:fix/scorecard-check-output-and-related-properties

Conversation

@colmcahalane-toast

@colmcahalane-toast colmcahalane-toast commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Two rendering defects in scorecard check results, found by comparing the plugin's output against the DX web UI for the same entity, plus a follow-on contrast fix.

Custom output units were pluralised twice

formatCustomOutputValue passed the author-supplied unit through pluralize(), which appends s to anything outside its special-case list. Units are already written in their intended form, so they came out doubled:

Unit configured in DX Before After
trace metrics 4 trace metricss 4 trace metrics
chars 89 charss 89 chars
monitors 71 monitorss 71 monitors
% time > 90% util 0.00 % time > 90% utils 0.00 % time > 90% util
image image
screenshot taken with different data,
count difference expected

The unit is now rendered verbatim, matching how DX's own UI displays it. pluralize() still serves the duration_* output types, whose units are hardcoded singulars (second, minute, …), so 1 day / 3 days behaviour is unchanged.

The related-property section never rendered

entities.scorecards returns related_properties as an array of property identifiers. The type and the drawer both expected a singular related_property string, which no response contains — so the "Related property / Edit in DX" block was dead code and never appeared for any check, on any entity.

Verified against a live API response: of 18 checks on one scorecard, 9 carried a related_properties value and none had a related_property key. The field is now correct and every entry in the array is rendered, with the label switching between singular and plural on count.

Before After
image image

Related-property chips were illegible on dark themes

Once the section above started rendering, the chip turned out to set a light background-color while leaving color inherited — near-white text on #F3F4F6, a contrast ratio of 1.1:1 under a dark theme. It now pairs the background with an explicit foreground, as CheckResultBadge already does for its status colours, giving 9.4:1.

image

Also included

  • CustomOutputOptions.unit was typed as the string literal "string" rather than string, making any real unit value a type error.
  • Unit tests for CheckResultBadge and CheckResultDrawer covering the above. These are the first component tests in the package; each one was confirmed to fail against the unfixed code.

Testing

yarn tsc, yarn lint, yarn format:check, yarn test and yarn build all pass. Also verified in a real Backstage instance (Backstage 1.51, dark theme) by installing the packed tarball, where the badge text and the related-property row both render as expected.


These changes were written with Claude Code and reviewed by me before submitting.

Two defects in how check results render, both found by comparing the
plugin against DX's own scorecard UI for the same entity.

Custom output units were pluralized before display, but the unit is
author-supplied and already written in its intended form. `pluralize()`
appends "s" to anything outside its special-case list, so units came out
doubled: "4 trace metricss", "89 charss". Render the unit verbatim, as
DX does. `pluralize()` still serves the duration_* output types, whose
units are hardcoded singulars.

The related-property section never rendered for any check. The API
returns `related_properties` as an array; the type and the drawer both
expected a singular `related_property` string, which no response
contains. Correct the field and render every property in the array.

Also fixes `CustomOutputOptions.unit`, typed as the string literal
"string" rather than `string`.
The chip set a light background but left the text color inherited, so
dark themes rendered near-white text on it at a 1.1:1 contrast ratio.
Pair the background with an explicit foreground, as the check result
badges already do.
@colmcahalane-toast
colmcahalane-toast marked this pull request as ready for review August 6, 2026 10:10
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.

1 participant