Page MenuHomePhabricator

detectType should always return string or throw exception ( TypeError: undefined is not an object (evaluating 'this.getMIMEType'))
Open, Needs TriagePublic

Description

https://gerrit.wikimedia.org/g/mediawiki/extensions/TimedMediaHandler/+/4cd087e9bfe465acf67cb7b94eb37c6ccff2897d/resources/mwembed/EmbedPlayer/mw.MediaSource.js#405

The function signature of detectType says that it always returns a string, however this is not true, in certain cases it returns void and logs a message.

mw.log( 'Error: could not detect type of media src: ' + uri );

It would be better to either:

  1. return an empty string
  2. throw an exception in this case so that a stake trace is visible in Logstash and actionable. Given there is no exception, the error is currently materializing further down the stack as TypeError: undefined is not an object (evaluating 'this.getMIMEType')

2 should only occur if there is an intention to fix the underlying error.

Event Timeline

Jdlrobson created this task.Sat, Aug 1, 8:40 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSat, Aug 1, 8:40 PM