Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error formatting bug in HTTP::CookieJar::AbstractStore #42

Merged

Conversation

andrelaszlo
Copy link
Contributor

@andrelaszlo andrelaszlo commented Feb 13, 2023

Before this patch is applied, the new test will fail:

     10:     end
     11: 
     12:     def test_nonexistent_store_in_config
  => 13:       assert_raise_with_message(
     14:         ArgumentError,
     15:         /cookie store unavailable: :nonexistent, error: cannot load .*nonexistent_store/
     16:       ) {
<ArgumentError> expected but was
<ArgumentError(<too few arguments>)

The bug seems to have been introduced a while back.

This line:

raise IndexError, 'cookie store unavailable: %s, error: %s' % symbol.inspect, e.message

Will be parsed as:

(send nil :raise
  (const nil :IndexError)
  (send
    (str "cookie store unavailable: %s, error: %s") :%
    (send
      (send nil :symbol) :inspect))
  (send
    (send nil :e) :message))

This means that the message will be passed as an argument to the IndexError initializer instead of to %.

If self contains multiple substitutions, object must be an Array or Hash containing the values to be substituted

String#% docs

@andrelaszlo andrelaszlo changed the title Abstract store fix error formatting bug Fix error formatting bug in HTTP::CookieJar::AbstractStore Feb 13, 2023
@andrelaszlo
Copy link
Contributor Author

We ran into this spurious issue when the HashStore wasn't in the @@class_map - likely an issue due to, or similar to #27.

@andrelaszlo
Copy link
Contributor Author

Ping @knu - any feedback on this PR? :)

@andrelaszlo
Copy link
Contributor Author

Ping @knu (or perhaps @leejarvis?) - this bug is still present in the library. I tried to follow the instructions in the Contributing section but maybe I missed something? 🤔

Copy link
Member

@knu knu left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, this looks perfect!

@knu knu merged commit 94e2b85 into sparklemotion:master Nov 13, 2023
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.

2 participants