Skip to content

Fetch current option values after mutation - #1690

Merged
olleolleolle merged 3 commits into
lostisland:mainfrom
OskarEichler:codex/fetch-current-option-values
Oct 13, 2026
Merged

olleolleolle merged 3 commits into
lostisland:mainfrom
OskarEichler:codex/fetch-current-option-values

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fetch current option values instead of a stale populated-key cache.

Reproduction and verification

RequestOptions.new.fetch(:timeout, 10), then fetch(: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.

  • Full RSpec suite: 644 examples, 0 failures; 94.98% line coverage.
  • Targeted RuboCop, Ruby syntax, and git diff --check pass.
  • Ruby 4.0.6 through rbenv. No production or live external HTTP operations.

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.

@iMacTia

iMacTia commented Oct 5, 2026

Copy link
Copy Markdown
Member

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 could try and justify myself with a combination of work, summer vacations and whatnot, but that would really be just finding excuses. I could have at least dropped you a message at some point. I'm really sorry about that.

I want to work through the PRs backlog and get on top of things again, and I noticed you've opened quite a few!
So I'd like to use this first PRs to ask you more about your thought process and the overall reason behind these PRs: are these driven by your personal/commercial experience with Faraday; or part of a bigger, over-arching design?

Knowing this would help reviewing them with the right mindset and potentially share more insights if needed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread lib/faraday/options.rb
# Public
def fetch(key, *args)
unless symbolized_key_set.include?(key.to_sym)
unless members.include?(key.to_sym) && !send(key).nil?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@olleolleolle
olleolleolle merged commit dc8c26b into lostisland:main Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants