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 app manifest errors #2349

Closed
wants to merge 2 commits into from
Closed

Report app manifest errors #2349

wants to merge 2 commits into from

Conversation

paulirish
Copy link
Member

fixes #2348

If the manifest has JSON errors, it currently fails with something like this:

But we do have more useful errors coming from protocol we could share... for example.

This PR implements that.
Also driveby to remove superfluous word "required"

Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

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

I know our driver tests are bonkers, but is this testable?

@brendankenny
Copy link
Member

a dbw_tester bad manifest might not be a terrible idea

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

I'd like to check this out on some bad manifests before we merge. I'm still stuck in the #1666 mindset, that we'll be dropping more detailed error messages from our parser because we'll never try parsing it. I don't know what the protocol considers critical errors though.

@brendankenny
Copy link
Member

I don't know what the protocol considers critical errors though.

at first glance it appears to only be used for JSON errors, but maybe there are errors higher up the chain that are also labeled critical? If not, not sure how we were labelling JSON parse errors as "unable to retrieve"...

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

looks like critical is just JSON parsing errors, so I'm good with doing this too :)

// We're not reading `response.errors` however it may contain critical and noncritical
// errors from Blink's manifest parser:
// https://chromedevtools.github.io/debugger-protocol-viewer/tot/Page/#type-AppManifestError
// handle errors
Copy link
Member

Choose a reason for hiding this comment

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

maybe make this explicit and say // Handle JSON syntax errors or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

sg. also detailed what issues these deal with.

// handle errors
if (response.errors) {
response.errors.forEach(error => {
log.warn('driver', 'Manifest error', error.message);
Copy link
Member

Choose a reason for hiding this comment

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

not sure if we want to warn on all of these (if it's not a critical warning the manifest is still functional, and we don't warn on something like all uncaught exceptions), but don't feel strongly :)

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 prefer warning on all for now. can quiet it if its annoying. But right now the repeated debugStrings in the report are the more annoying thing.

});
const criticalError = response.errors.find(error => error.critical);
if (criticalError) {
return reject(new Error(`Manifest error: ${criticalError.message}`));
Copy link
Member

Choose a reason for hiding this comment

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

while you're in here, do you want to flatten this promise? Rather than wrapping, can just return this.sendCommand()... and these return reject(new Error())s can just be throw new Error()

Copy link
Member Author

Choose a reason for hiding this comment

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

patrick did this mostly in #2549

@paulirish
Copy link
Member Author

updated. @brendankenny ptal

throw new Error(`Manifest error: ${criticalError.message}`);
}
}
// Handle failed manifest request or 404
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't usually work (or even get this far), fyi. DevTools will happily try to parse a 404 response like "Cannot GET /no-manifest.json" and return a JSON.parse error instead of the fact that it 404ed

Copy link
Member Author

Choose a reason for hiding this comment

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

ah! good call. thanks.

// Possible critical issues: invalid JSON (location reported) or manifest root is an array
const criticalError = response.errors.find(error => error.critical);
if (criticalError) {
throw new Error(`Manifest error: ${criticalError.message}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We really don't want errors like these reported to Sentry, but this does seem like a valid thing to display as a fatal error for an audit, I guess we should bring back ExpectedError?

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.

'Unable to retrieve manifest' when manifest file is available but invalid
4 participants