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

Breaking change in pg 1.4.0? PG::Error signature changed #466

Closed
dentarg opened this issue Jun 21, 2022 · 3 comments · Fixed by #467
Closed

Breaking change in pg 1.4.0? PG::Error signature changed #466

dentarg opened this issue Jun 21, 2022 · 3 comments · Fixed by #467

Comments

@dentarg
Copy link

dentarg commented Jun 21, 2022

Before 1.4.0 it was possible to raise PG errors without any arguments: https://github.com/ged/ruby-pg/blob/v1.3.5/lib/pg/exceptions.rb

$ ruby -rpg -e 'p PG::VERSION; raise PG::InvalidTextRepresentation'
"1.3.5"
-e:1:in `<main>': PG::InvalidTextRepresentation (PG::InvalidTextRepresentation)

With 1.4.0 it is not: https://github.com/ged/ruby-pg/blob/v1.4.0/lib/pg/exceptions.rb

$ ruby -rpg -e 'p PG::VERSION; raise PG::InvalidTextRepresentation'
"1.4.0"
/Users/dentarg/.gem/ruby/3.1.2/gems/pg-1.4.0/lib/pg/exceptions.rb:10:in `initialize': wrong number of arguments (given 0, expected 1) (ArgumentError)
	from -e:1:in `exception'
	from -e:1:in `raise'
	from -e:1:in `<main>'
larskanis added a commit to larskanis/ruby-pg that referenced this issue Jun 21, 2022
Not used in our code, but some users do this and it used to work in pg<1.4.0.

Fixes ged#466
@jrafanie
Copy link

jrafanie commented Jun 22, 2022

@larskanis thanks for the fix in #467. I'd like to request a new release with this change.

In our example, we had PG connection code with tests verifying how we handled exceptions raised at the PG level.

expect(Foo).to receive(:bar).and_raise(PG::Error)

This started breaking in 1.4.0 with the change to the exception's interface.

We can fix it with:

expect(Foo).to receive(:bar).and_raise(PG::Error(''))

But this is less than optimal so we'd like to use 1.4.1 with this fix in it.

Thanks in advance!

jrafanie added a commit to jrafanie/manageiq that referenced this issue Jun 23, 2022
pg 1.4.0 was released with a breaking change to the interface for the PG::Error
class:

ged/ruby-pg@91b00d0

It was repored in ged/ruby-pg#466
and fixed in ged/ruby-pg#467 but not yet released.

1.4.0  was breaking our pg logical spec as seen below
 1) PglogicalSubscription#backlog returns nil if error raised inside
     Failure/Error:
       MiqRegionRemote.with_remote_connection(host, port || 5432, user, decrypted_password, dbname, "postgresql", connect_timeout) do |conn|
         yield conn
       end
     ArgumentError:
       wrong number of arguments (given 0, expected 1)
     # ./app/models/pglogical_subscription.rb:294:in `with_remote_connection'
     # ./app/models/pglogical_subscription.rb:289:in `remote_region_lsn'
     # ./app/models/pglogical_subscription.rb:104:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:495:in `block (3 levels) in <top (required)>'
jrafanie added a commit to jrafanie/manageiq that referenced this issue Jun 23, 2022
pg 1.4.0 was released with a breaking change to the interface for the PG::Error
class:

ged/ruby-pg@91b00d0

It was reported in ged/ruby-pg#466
and fixed in ged/ruby-pg#467 but not yet released.

1.4.0  was breaking our pg logical spec as seen below
 1) PglogicalSubscription#backlog returns nil if error raised inside
     Failure/Error:
       MiqRegionRemote.with_remote_connection(host, port || 5432, user, decrypted_password, dbname, "postgresql", connect_timeout) do |conn|
         yield conn
       end
     ArgumentError:
       wrong number of arguments (given 0, expected 1)
     # ./app/models/pglogical_subscription.rb:294:in `with_remote_connection'
     # ./app/models/pglogical_subscription.rb:289:in `remote_region_lsn'
     # ./app/models/pglogical_subscription.rb:104:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:495:in `block (3 levels) in <top (required)>'
@larskanis
Copy link
Collaborator

pg-1.4.1 is pushed with the above fix to PG::Error.

jrafanie added a commit to jrafanie/manageiq that referenced this issue Jun 24, 2022
1.4.0 led to ged/ruby-pg#466
and was fixed in ged/ruby-pg#467

Since 1.4.1 is now released and fixes the issue, we can safely unlock pg except
for version 1.4.0.
@jrafanie
Copy link

Thank you @larskanis. 1.4.1 works for us. 🙇

iv1111 pushed a commit to iv1111/manageiq that referenced this issue Jun 28, 2022
pg 1.4.0 was released with a breaking change to the interface for the PG::Error
class:

ged/ruby-pg@91b00d0

It was reported in ged/ruby-pg#466
and fixed in ged/ruby-pg#467 but not yet released.

1.4.0  was breaking our pg logical spec as seen below
 1) PglogicalSubscription#backlog returns nil if error raised inside
     Failure/Error:
       MiqRegionRemote.with_remote_connection(host, port || 5432, user, decrypted_password, dbname, "postgresql", connect_timeout) do |conn|
         yield conn
       end
     ArgumentError:
       wrong number of arguments (given 0, expected 1)
     # ./app/models/pglogical_subscription.rb:294:in `with_remote_connection'
     # ./app/models/pglogical_subscription.rb:289:in `remote_region_lsn'
     # ./app/models/pglogical_subscription.rb:104:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:495:in `block (3 levels) in <top (required)>'
iv1111 pushed a commit to iv1111/manageiq that referenced this issue Jun 28, 2022
1.4.0 led to ged/ruby-pg#466
and was fixed in ged/ruby-pg#467

Since 1.4.1 is now released and fixes the issue, we can safely unlock pg except
for version 1.4.0.
GilbertCherrie pushed a commit to GilbertCherrie/manageiq that referenced this issue Jul 7, 2023
pg 1.4.0 was released with a breaking change to the interface for the PG::Error
class:

ged/ruby-pg@91b00d0

It was reported in ged/ruby-pg#466
and fixed in ged/ruby-pg#467 but not yet released.

1.4.0  was breaking our pg logical spec as seen below
 1) PglogicalSubscription#backlog returns nil if error raised inside
     Failure/Error:
       MiqRegionRemote.with_remote_connection(host, port || 5432, user, decrypted_password, dbname, "postgresql", connect_timeout) do |conn|
         yield conn
       end
     ArgumentError:
       wrong number of arguments (given 0, expected 1)
     # ./app/models/pglogical_subscription.rb:294:in `with_remote_connection'
     # ./app/models/pglogical_subscription.rb:289:in `remote_region_lsn'
     # ./app/models/pglogical_subscription.rb:104:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:495:in `block (3 levels) in <top (required)>'
GilbertCherrie pushed a commit to GilbertCherrie/manageiq that referenced this issue Jul 7, 2023
1.4.0 led to ged/ruby-pg#466
and was fixed in ged/ruby-pg#467

Since 1.4.1 is now released and fixes the issue, we can safely unlock pg except
for version 1.4.0.
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 a pull request may close this issue.

3 participants