Skip to content

Fix movie width and frame_rate returning nil#14357

Merged
Gargron merged 3 commits intomastodon:masterfrom
fedibird:fix-movie-width-and-frame_rate-nil
Jul 19, 2020
Merged

Fix movie width and frame_rate returning nil#14357
Gargron merged 3 commits intomastodon:masterfrom
fedibird:fix-movie-width-and-frame_rate-nil

Conversation

@noellabo
Copy link
Copy Markdown
Contributor

NoMethodError (undefined method `*' for nil:NilClass)

Add a nil check, as it can be nil

Comment thread app/models/media_attachment.rb Outdated

raise Mastodon::DimensionsValidationError, "#{movie.width}x#{movie.height} videos are not supported" if movie.width * movie.height > MAX_VIDEO_MATRIX_LIMIT
raise Mastodon::DimensionsValidationError, "#{movie.frame_rate.to_i}fps videos are not supported" if movie.frame_rate > MAX_VIDEO_FRAME_RATE
raise Mastodon::DimensionsValidationError, "#{movie.width}x#{movie.height} videos are not supported" if movie.width.nil? || movie.width * movie.height > MAX_VIDEO_MATRIX_LIMIT
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, this will raise error "x videos are not supported". I am not sure if it is necessary to raise these errors if there is no video stream. Perhaps raise another error like "Video has no video stream" before if movie.width.nil? || movie.frame_rate.nil??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That sounds better. Change.

@noellabo
Copy link
Copy Markdown
Contributor Author

Raise StreamValidationError instead of DimensionsValidationError.
Is it better to use VideoStreamValidationError or just ValidationError?

@Gargron Gargron merged commit 7540e23 into mastodon:master Jul 19, 2020
shouo1987 pushed a commit to CrossGate-Pawoo/mastodon that referenced this pull request Dec 7, 2022
* Fix movie width and frame_rate returning nil

* Add StreamValidationError and raise

* Fix code style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants