Shopify / Shopify/tapioca

IdentityCache compiler generates wrong return types for `fetch_multi_n_by_m` fields

Open
#1,770 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

After implementing the missing fetch_multi_n_by_m methods in https://github.com/Shopify/tapioca/pull/1758 I have found out that the method signature isn't always correct as shown in this example from cache_attribute: https://github.com/Shopify/identity_cache/blob/main/lib/identity_cache/cached/attribute.rb#L82-L101

The result of methods that include by in the name is a hash where:

  • Key: type m (be it a single value or an array of multiple)
  • Value: type n or T::Array[n] depending on things like if unique has been passed to cache_attribute.

So at present when the return type is T::Array[n], it would be expected that it is actually T::Hash[T.untyped, n] or T::Hash[T.untyped, T::Array[n]] based on how it was created.

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

Inspect the linked IdentityCache entry point, lib/identity_cache/cached/attribute.rb around lines 82-101, and the fetch_multi_n_by_m method generation from PR #1758. Compare generated signatures with the cache_attribute unique behavior; done means the return type uses the appropriate hash key type and n or T::Array[n] value type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.