Skip to content

Fix NoMethodError in copy_files for unknown mime types (webp)#72513

Open
fisher-alice wants to merge 3 commits intostagingfrom
alice/copy-assets-error
Open

Fix NoMethodError in copy_files for unknown mime types (webp)#72513
fisher-alice wants to merge 3 commits intostagingfrom
alice/copy-assets-error

Conversation

@fisher-alice
Copy link
Copy Markdown
Contributor

@fisher-alice fisher-alice commented May 5, 2026

We recently started supporting webp files in #72228, and added a default mime type for webp in #72276 for get_file in files_api.rb since Rack does not provide the mime type for this file type. However, it appears like we are getting a similar error for copy_files in bucket_helper.rb so we update the global Rack MIME types table to include webp and md.

Links

Testing story

  • Added a couple unit tests.
  • Locally, I confirmed on a Web Lab level that I can create a md file, save it to backpack and then add it to a project on a different level.

Currently, webp files are supported when a model generates the image. I am a little puzzled on how webp files are being added to projects as they are NOT explicitly supported in the Animation Picker, the Assets Uploader nor the Lab2 Uploader.
It seems like we're hitting this error when we're copying assets over (like when a user remixes a project), but unsure how webp files are being added to begin with. It seems like these HoneyBadger errors began when we started supporting webp files (April 22). We know that users are uploading files whose file extensions are not accurate. See #72152. We will continue monitoring.

Deployment notes

Privacy and security

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a NoMethodError during project/asset copy when an uploaded file’s extension is missing from the MIME type table (notably .webp), and aligns file serving to use globally-registered MIME mappings.

Changes:

  • Prevents copy_files from crashing when Sinatra::Base.mime_type returns nil for an extension.
  • Registers missing MIME types (.webp, .md) in Rack’s global MIME table so Sinatra/Rack resolution works consistently.
  • Simplifies get_file content type handling by removing per-request default overrides and relying on the global MIME table.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
dashboard/legacy/middleware/helpers/bucket_helper.rb Avoids split on a nil MIME type when copying files.
dashboard/legacy/middleware/files_api.rb Registers .webp/.md MIME types globally and simplifies content_type usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dashboard/legacy/middleware/helpers/bucket_helper.rb Outdated
Comment thread dashboard/legacy/middleware/helpers/bucket_helper.rb Outdated
Comment thread dashboard/legacy/middleware/files_api.rb
@fisher-alice fisher-alice marked this pull request as ready for review May 5, 2026 16:25
@fisher-alice fisher-alice requested review from a team and sanchitmalhotra126 May 5, 2026 16:25
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