Problem/Motivation

When we try to reference a YouTube video URL on Media Remote Video form without YouTube process finish, one error to report on Database log is generated but the error message throws an exception to log on database.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xFF\xD8\xFF\xE0\x00\x10...' for column 'message' at row 1: INSERT INTO "watchdog" ("uid", "type", "message", "variables", "severity", "link", "location", "referer", "hostname", "timestamp") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => media [:db_insert_placeholder_2] => Client error: `GET https://i.ytimg.com/vi/zTXZeHc_93s/hqdefault.jpg` resulted in a `404 Not Found` response: ���JFIF���    !"" (truncated...) [:db_insert_placeholder_3] => a:0:{} [:db_insert_placeholder_4] => 4 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => https://drupal.site/media-library?_wrapper_format=drupal_ajax&ajax_form=1&hash=Qkg0G8WJcT7LbcUjOp81t1osRKvqWFalkPaQG1YP8ck&media_library_allowed_types%5B0%5D=image&media_library_allowed_types%5Baudio%5D=audio&media_library_allowed_types%5Bdocument%5D=document&media_library_allowed_types%5Bremote_video%5D=remote_video&media_library_allowed_types%5Bvideo%5D=video&media_library_opener_id=media_library.opener.editor&media_library_opener_parameters%5Bfilter_format_id%5D=full_html&media_library_remaining=1&media_library_selected_type=remote_video [:db_insert_placeholder_7] => https://drupal.site/node/add/page [:db_insert_placeholder_8] => 127.0.0.1 [:db_insert_placeholder_9] => 1663630569 ) in Drupal\dblog\Logger\DbLog->log() (line 78 of /app/web/core/modules/dblog/src/Logger/DbLog.php).

Steps to reproduce

  1. Upload a new video on YouTube.
  2. Try to refernce on Add Remote video via URL field before YouTube finishes the process.
  3. Check Database logs to see the message

Proposed resolution

Replace direct error message output by a output string with token replacement.
Before:

$this->logger->warning($e->getMessage());

After:

$this->logger->warning('Failed to video thumbnail file due to "%error".', ['%error' => $e->getMessage()]);

Issue fork drupal-3310510

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

igorbarato created an issue. See original summary.

igor.barato’s picture

Status: Active » Needs review
anchal_gupta’s picture

StatusFileSize
new727 bytes
new624 bytes

Fixed CS Error

wim leers’s picture

Title: Media Remote Video error to fetch default YouTube thumbnail » Harden error logging of OEmbed thumbnail fetching logic (YouTube errors contain special characters)
Status: Needs review » Reviewed & tested by the community
Issue tags: +hardening

Oh, interesting! This seems like an encoding problem, and wrapping it in FormattableMarkup solves that. Interesting side-effect, but also totally reasonable and harmless! I like it 🤓

Tests are overkill in this case IMO.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed c36f03ae2b to 10.1.x and d02fe902da to 10.0.x and 172f01a6a2 to 9.5.x and 85df6364af to 9.4.x. Thanks!

Backported to 9.4.x since this is a useful bugfix. Agree with #5 tests aren't that helpful here.

  • alexpott committed c36f03a on 10.1.x
    Issue #3310510 by igorbarato, Anchal_gupta: Harden error logging of...

  • alexpott committed d02fe90 on 10.0.x
    Issue #3310510 by igorbarato, Anchal_gupta: Harden error logging of...

  • alexpott committed 172f01a on 9.5.x
    Issue #3310510 by igorbarato, Anchal_gupta: Harden error logging of...

  • alexpott committed 85df636 on 9.4.x
    Issue #3310510 by igorbarato, Anchal_gupta: Harden error logging of...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.