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

Media3P: Add hardening for missing media URLs #12091

Merged
merged 6 commits into from
Aug 16, 2022

Conversation

timarney
Copy link
Contributor

@timarney timarney commented Aug 9, 2022

Context

The third part media / Gif tab is failing to load -- it throws a snackbar error.

Summary

Updates sortMediaBySize to early return if media urls don't get passed to the parameters.

In this case after filtering we can end up with an empty array

const webmSizes = sortMediaBySize(
    m,
    m.videoUrls.filter(({ mimeType }) => mimeType === 'image/webm')
  );

causing the eventual width / height check to fail

originalWidth: mediaUrls[0].width,
originalHeight: mediaUrls[0].height,

See: #12083 (comment)

Relevant Technical Choices

To-do

User-facing changes

Testing Instructions

  • This is a non-user-facing change and requires no QA

This PR can be tested by following these steps:

  1. "fresh load of the page" (full reload)
  2. Visit the Gif tab
  3. Scroll to load images - note the tab loads and doesn't throw an error.

Reviews

Does this PR have a security-related impact?

no

Does this PR change what data or activity we track or use?

Added error tracking for for fetch media

Does this PR have a legal-related impact?

no

Checklist

  • This PR addresses an existing issue and I have linked this PR to it in ZenHub
  • I have tested this code to the best of my abilities
  • I have verified accessibility to the best of my abilities (docs)
  • I have verified i18n and l10n (translation, right-to-left layout) to the best of my abilities
  • This code is covered by automated tests (unit, integration, and/or e2e) to verify it works as intended (docs)
  • I have added documentation where necessary
  • I have added a matching Type: XYZ label to the PR

Fixes #12083

@timarney timarney added Group: Media Group: 3P Media Third-party media provider integrations. Type: Bug Something isn't working Pod: WP labels Aug 9, 2022
…3p.js

Co-authored-by: Pascal Birchler <pascalb@google.com>
@timarney timarney self-assigned this Aug 10, 2022
@timarney
Copy link
Contributor Author

timarney commented Aug 10, 2022

@swissspidy I added a trackError to help surface anything that might come up in the future.

@timarney timarney marked this pull request as ready for review August 10, 2022 09:06
Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Just one nit, otherwise LGTM

@swissspidy swissspidy changed the title Media3P: GIFs Tab not working Media3P: Add hardening for missing media URLs Aug 10, 2022
@googleforcreators-bot
Copy link
Collaborator

Plugin builds for f042260 are ready 🛎️!

@swissspidy swissspidy merged commit f9b26d9 into main Aug 16, 2022
@swissspidy swissspidy deleted the fix/12083-gifs-tab-not-working branch August 16, 2022 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Media Group: 3P Media Third-party media provider integrations. Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media3P: GIFs Tab not working
3 participants