Skip to content

Normalize response types consistently when clearing responses - #747

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/responses-imap
Open

Normalize response types consistently when clearing responses#747
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/responses-imap

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Normalize response types with to_s.upcase in clear_responses, matching responses(type) and extract_responses(type). Lowercase/mixed-case strings and symbols can currently read a response but silently fail to remove it.

Reproduction

require 'net/imap'
imap = Net::IMAP.allocate
imap.send(:mon_initialize)
imap.instance_variable_set(:@responses, {'EXISTS' => [3]})
p imap.responses(:exists) # [3]
p imap.clear_responses(:exists) # before: []; after: [3]

Verification

  • 90 focused checks, 20 failing expectations before and zero afterward. Five string/symbol case variants, empty/nonempty response lists, actual key deletion, unrelated-response retention, frozen output and repeated clearing are covered. The original 💥 Changes to responses handling, motivated by thread-safety #93 introduced both methods; its source was reviewed.
  • Existing rake test on this isolated branch: 1726 tests, 12602 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications, Ruby 4.0.6 via rbenv. Baseline also passes 1,726 tests; assertion counts vary slightly between runs.
  • Supplemental RuboCop Lint retains the same 48 existing findings. Syntax and git diff --check pass. No new/modified repository tests, dependencies or workflows; focused checks were external under the consumer repository's no-new-tests policy.
  • Based on master 6d2ef7a636a1e2449187a83b06ac7a5baa54ead2; runtime differs from released 0.6.6 only in documentation before this change. Existing upstream PR searches found no matching fix.

Compatibility and limits

Intentional correction: noncanonical type spellings now clear the corresponding canonical response key. Uppercase strings, nil/false whole-hash clearing and result freezing retain their existing behavior. This does not alter raw response-hash mutation policy. No production or external IMAP service used. Other Ruby/OS versions were not run locally. Local success does not imply upstream CI approval or exhaustive coverage.

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.

1 participant