basecamp / basecamp/once-campfire
Avatar and account logo rendering fails with S3-backed Active Storage
- Dominant language
- Ruby
- Stars
- 4.6k
- Forks
- 791
- Avg merge
- 11h 8m
- Merged PRs (30d)
- 13
Description
## 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
```ruby
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`.
Contributor guide
Research direction
Start with app/controllers/users/avatars_controller.rb and app/controllers/accounts/logos_controller.rb, tracing how each serves the processed representation after upload. Reproduce with ACTIVE_STORAGE_SERVICE=s3 against an S3-compatible backend such as MinIO; done means uploaded avatars and account logos render without the path_for error and the follow-up image request no longer returns 500.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100