Summary
In Flipper::Adapters::ActiveSupportCacheStore#write_options, the race_condition_ttl option is never actually passed to @cache.fetch / @cache.write because the assignment operator is missing. The option has been silently broken since it was introduced in #932.
Location
lib/flipper/adapters/active_support_cache_store.rb#L78-L83 on main:
def write_options
write_options = {}
write_options[:expires_in] = @ttl if @ttl
write_options[:race_condition_ttl] if @race_condition_ttl # ← no-op
write_options
end
The third line reads write_options[:race_condition_ttl] (which returns nil on a freshly-created empty hash with no default) and discards the result. It should be:
write_options[:race_condition_ttl] = @race_condition_ttl if @race_condition_ttl
Impact
Anyone configuring the adapter with race_condition_ttl: gets the option accepted without error and exposed via the race_condition_ttl reader, but it never reaches ActiveSupport::Cache::Store. The thundering-herd protection users expect from race_condition_ttl is not actually in effect.
How it slipped through
#932 added both the feature and the bug in a single commit. The accompanying specs in spec/flipper/adapters/active_support_cache_store_spec.rb only assert that the constructor sets the reader (expect(adapter.race_condition_ttl).to eq(race_condition_ttl)). There's no behavioral test that @cache.fetch / @cache.write actually receives race_condition_ttl in its options hash, so the typo wasn't caught.
Proposed fix
- Add the missing
= @race_condition_ttl in write_options.
- Add a spec that stubs
cache.fetch (or uses a cache double) and asserts the options hash includes race_condition_ttl: <value> when the adapter was constructed with one.
Happy to open a PR for this if it'd be helpful.
How it was found
Caught by Cursor Bugbot during review of a downstream PR that vendors this adapter file. I verified against main that the bug is still present.
Summary
In
Flipper::Adapters::ActiveSupportCacheStore#write_options, therace_condition_ttloption is never actually passed to@cache.fetch/@cache.writebecause the assignment operator is missing. The option has been silently broken since it was introduced in #932.Location
lib/flipper/adapters/active_support_cache_store.rb#L78-L83onmain:The third line reads
write_options[:race_condition_ttl](which returnsnilon a freshly-created empty hash with no default) and discards the result. It should be:Impact
Anyone configuring the adapter with
race_condition_ttl:gets the option accepted without error and exposed via therace_condition_ttlreader, but it never reachesActiveSupport::Cache::Store. The thundering-herd protection users expect fromrace_condition_ttlis not actually in effect.How it slipped through
#932 added both the feature and the bug in a single commit. The accompanying specs in
spec/flipper/adapters/active_support_cache_store_spec.rbonly assert that the constructor sets the reader (expect(adapter.race_condition_ttl).to eq(race_condition_ttl)). There's no behavioral test that@cache.fetch/@cache.writeactually receivesrace_condition_ttlin its options hash, so the typo wasn't caught.Proposed fix
= @race_condition_ttlinwrite_options.cache.fetch(or uses a cache double) and asserts the options hash includesrace_condition_ttl: <value>when the adapter was constructed with one.Happy to open a PR for this if it'd be helpful.
How it was found
Caught by Cursor Bugbot during review of a downstream PR that vendors this adapter file. I verified against
mainthat the bug is still present.