Repository navigation
Fetch current option values after mutation - #1690
olleolleolle merged 3 commits into
Conversation
|
Hey @OskarEichler 👋 First of all, I'd like to apologise for keeping your PRs waiting for more than a month, that's not cool. I want to work through the PRs backlog and get on top of things again, and I noticed you've opened quite a few! Knowing this would help reviewing them with the right mindset and potentially share more insights if needed. |
There was a problem hiding this comment.
🟡 Changes recommended
The bug fix needs committed regression tests to protect its mutation-related behavior in CI.
1 open finding
What changed in this PR
Updates Faraday::Options#fetch to read current values instead of relying on a stale key cache.
Changes:
- Checks live option values during
fetch. - Rebuilds the symbolized key set on demand.
| File | Description |
|---|---|
lib/faraday/options.rb |
Corrects default-fetch behavior after option mutation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Public | ||
| def fetch(key, *args) | ||
| unless symbolized_key_set.include?(key.to_sym) | ||
| unless members.include?(key.to_sym) && !send(key).nil? |
There was a problem hiding this comment.
Added committed regression examples in b071986 for repeated fetch after installing a default, replacing a value, delete and clear, plus false values, string keys, and block evaluation. The full RSpec suite passes on Ruby 4.0.6 (644 examples, 0 failures; coverage 94.98%); targeted RuboCop, Ruby syntax, and git diff --check pass.

Summary
Fetch current option values instead of a stale populated-key cache.
Reproduction and verification
RequestOptions.new.fetch(:timeout, 10), thenfetch(:timeout, 20), returns 10 both times. After deletion the next fetch installs its new default. The committed regression examples also cover value replacement,clear, false values, string keys, and block evaluation.git diff --checkpass.Breaking-change notes
Preserves existing write-back defaults. Does not implement the Options architecture refactor in #1644. The PR contains only the focused source fix and its regression examples.