Skip to content

Avatar and account logo rendering fails with S3-backed Active Storage #186

@joshyorko

Description

@joshyorko

Summary

When ACTIVE_STORAGE_SERVICE is set to s3, custom user avatars and account logos upload successfully but fail to render afterward.

This happens because the controllers call ActiveStorage::Blob.service.path_for(...), which works for DiskService but raises on ActiveStorage::Service::S3Service.

Reproduction

  1. Configure Campfire production storage to use ACTIVE_STORAGE_SERVICE=s3.
  2. Point it at any S3-compatible backend.
    • I reproduced this with MinIO, but this should affect any ActiveStorage::Service::S3Service backend.
  3. Upload a user avatar from /users/me/profile.
  4. Optionally upload an account logo as well.

Expected

The uploaded avatar/logo should render normally.

Actual

The upload succeeds, but the follow-up image request returns 500 and the UI shows a broken image.

Error

NoMethodError (undefined method 'path_for' for an instance of ActiveStorage::Service::S3Service)

Affected code paths on main:

  • app/controllers/users/avatars_controller.rb
  • app/controllers/accounts/logos_controller.rb

Notes

In my reproduction, the blob upload and subsequent download both succeeded. The failure happens only when the controller tries to serve the processed variant back using the disk-only path_for API.

The fix was to stream the processed representation through Active Storage instead of reading it via path_for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions