Shopify / Shopify/identity_cache

Prevent cache_belongs_to from being used with a has_one association

Open
#361 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2k
Forks
174
Avg merge
13m
Merged PRs (30d)
3

Description

I noticed in https://github.com/Shopify/identity_cache/pull/360#discussion_r153844042 that this can happen without an exception. There are assumptions in cache_belongs_to that I think would lead to inefficient queries and cache corruption.

Contributor guide

Open the contributing guide

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 reviewing the cache_belongs_to implementation and the referenced discussion in pull request #360. Trace how a has_one association is currently accepted, then verify that such use is prevented and that valid cache_belongs_to behavior remains unchanged.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.