Shopify / Shopify/tapioca

ActiveStorage dynamic proxy methods not surfaced

Open
#376 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
873
Forks
164
Avg merge
4d 27m
Merged PRs (30d)
9

Description

I'm actually not 100% sure if this issue belongs here, in sorbet-rails, or somewhere else. Please redirect me to wherever would have responsibility for this!

ActiveStorage has been designed to having you go through the ActiveStorage::Attached::One proxy that provides the dynamic proxy to the associations and factory methods

However, generated RBIs do not include those proxy methods, which means operations like model.file.**open** raise a typechecking error, despite that method both existing and working. A workaround is to use model.file**_blob**.open, but this is not the documented API so I'm nervous using it - I imagine it's more likely to change in future.

I'd expect the RBI for ActiveStorage::Attached::One to include these methods so that typechecking can be used when accessing the files as documented.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how Tapioca generates RBIs for ActiveStorage::Attached::One and compare the generated interface with ActiveStorage's documented proxy methods. Done means the generated RBI exposes methods such as open so typechecking accepts documented calls like model.file.open without requiring model.file_blob.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.