Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: handle missing credits when rendering meta block #13350

Merged
merged 8 commits into from
Nov 10, 2021
Merged

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Nov 10, 2021

LHR PSI json doesn't have this field currently.

I'm adding it but we need to make sure this doesnt throw in the meantime.

this'll break new /measure (using v9 renderer) in the meantime.

@paulirish paulirish requested a review from a team as a code owner November 10, 2021 00:18
@paulirish paulirish requested review from adamraine and removed request for a team November 10, 2021 00:18
@google-cla google-cla bot added the cla: yes label Nov 10, 2021
@@ -127,7 +127,7 @@ export class ReportRenderer {
: 'Chromium';
const channel = report.configSettings.channel;
const benchmarkIndex = report.environment.benchmarkIndex.toFixed(0);
const axeVersion = report.environment.credits['axe-core'];
const axeVersion = report.environment.credits && report.environment.credits['axe-core'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const axeVersion = report.environment.credits && report.environment.credits['axe-core'];
const axeVersion = report.environment.credits?.['axe-core'];

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead, shouldn't we fix this in prepareReportResult? I'd expect the renderer to break with older LHRs w/o credits.

Copy link
Member Author

Choose a reason for hiding this comment

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

i mean... i'd love that, but don't we have an incompatibility in our tooling stack?

(perhaps it was browserify?)

even if we're 100% gtg here, i'd much rather do this ?. upgrade in a bulk-change PR than introduce it with this one PR that i need for v9.

Copy link
Member

Choose a reason for hiding this comment

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

before #13125 the renderer also did a check for report.environment.credits before accessing, so I'd personally be fine with keeping it local. prepareReportResult seems like it should be reserved for things we really need as opposed to more optional metadata.

We should probably make the property optional to make sure it's always checked, though.

Copy link
Member

@brendankenny brendankenny Nov 10, 2021

Choose a reason for hiding this comment

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

i mean... i'd love that, but don't we have an incompatibility in our tooling stack?

(perhaps it was browserify?)

it was browserify, but it would also still be fine because this is in the renderer, so it's browser only (and node for a unit test without any bundling)

even if we're 100% gtg here, i'd much rather do this ?. upgrade in a bulk-change PR than introduce it with this one PR that i need for v9.

haha, a mass change sounds worse to me rather than starting to use it as needed :)

Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably make the property optional to make sure it's always checked, though.

this is basically Report: add more robust handling of default property values stripped by LHR proto · #12868

it was browserify, but it would also still be fine because this is in the renderer, so it's browser only (and node for a unit test without any bundling)

k thanks for the confirmation.

Copy link
Member

@brendankenny brendankenny Nov 10, 2021

Choose a reason for hiding this comment

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

We should probably make the property optional to make sure it's always checked, though.

this is basically Report: add more robust handling of default property values stripped by LHR proto · #12868

Yeah, fair point. I guess I was thinking differently about it because it was meant to be optionally handled from the start, so we should have just typed it like that instead of setting it as required but handling the optional fallback in the renderer. Without the type the next refactor was bound to remove the check.

We should probably write down guidance for ourselves for both robust handling of trips through proto space and easing compatibility with old LHRs so we don't forget it all every 18 months or so :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The separate consideration of some types to be optional on the LHR (when they really would always exist in the latest LH run) is confusing IMO. The "fixup" is simple enough (empty object for credits, done in the same place with fixup all other things about older LHRs before rendering), although for this property in particular that still leaves us needing to check the existence of the axe-core key (can we change the type to Record<string, string|undefined>?).

@connorjclark connorjclark changed the title report: add safety check for handling LHRs from PSI report: handle missing credits when rendering meta block Nov 10, 2021
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.

5 participants