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

Fix movie width and frame_rate returning nil #14357

Merged
merged 3 commits into from
Jul 19, 2020

Conversation

noellabo
Copy link
Contributor

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

Add a nil check, as it can be nil

@@ -336,8 +336,8 @@ def check_video_dimensions

return unless movie.valid?

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
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
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
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