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

Row.decode(…) fails for enum type with IllegalArgumentException: 72093 is not a valid object id #301

Closed
1 of 4 tasks
mp911de opened this issue Jul 22, 2020 · 15 comments · Fixed by #317
Closed
1 of 4 tasks
Labels
status: first-timers-only An issue that can only be worked on by brand new contributors status: in-progress An issue that is currently being worked on type: bug A general bug
Milestone

Comments

@mp911de
Copy link
Collaborator

mp911de commented Jul 22, 2020

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open-source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general ideal-for-contribution issues. Thanks!

Problem

AbstractTemporalCodec.canDecode fails as it tries to create a PostgresqlObjectId to verify whether it can decode a timestamp. OID 72093 is a custom type that isn't known by PostgresqlObjectId and AbstractTemporalCodec.canDecode should not fail, it should rather report that it cannot decode the value by returning false.

As user, calling Row.get(…) leads to:

java.lang.IllegalArgumentException: 72093 is not a valid object id
	at io.r2dbc.postgresql.type.PostgresqlObjectId.valueOf(PostgresqlObjectId.java:417)
	at io.r2dbc.postgresql.codec.AbstractTemporalCodec.canDecode(AbstractTemporalCodec.java:69)
	at io.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:128)
	at io.r2dbc.postgresql.PostgresqlRow.decode(PostgresqlRow.java:90)
	at io.r2dbc.postgresql.PostgresqlRow.get(PostgresqlRow.java:77)
	at io.r2dbc.spi.Row.get(Row.java:78)

Solution

AbstractTemporalCodec.canDecode(…) should make use of PostgresqlObjectId.isValid(dataType) before looking up the default type from PostgresqlObjectId. Other codecs such as AbstractCodec are performing the check correctly.

Steps to Fix

  • Claim this issue with a comment below and ask any clarifying questions you need
  • Set up a repository locally following the Contributing Guidelines
  • Try to fix the issue following the steps above
  • Commit your changes and start a pull request.
@mp911de mp911de added the type: bug A general bug label Jul 22, 2020
@mp911de mp911de added this to the 0.8.5.RELEASE milestone Jul 22, 2020
@mp911de mp911de added the status: first-timers-only An issue that can only be worked on by brand new contributors label Jul 22, 2020
@AlbertMMM
Copy link

@mp911de I would like to claim this issue. I have the the repository locally set up and I'm able to run the tests. Can you please point me in the right direction to mocking As user, calling Row.get(…)?

@mp911de mp911de added the status: in-progress An issue that is currently being worked on label Jul 27, 2020
@mp911de
Copy link
Collaborator Author

mp911de commented Jul 27, 2020

You're welcome @AlbertMMM. I would suggest starting with a test for canDecode using a subclass of AbstractTemporalCodec, e.g. InstantCodec. Codecs are used from PostgresqlRow. However mocking PostgresqlRow along with all the required objects (column descriptors, row data) would impose a lot of work and it would be a test with many directions. Therefore, I suggest starting on the codec level directly.

Let us know if you need any further details.

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 13, 2020

Since the submitted pull request had to be closed due to inactivity, this ticket is up for grabs again.

@mp911de mp911de removed the status: in-progress An issue that is currently being worked on label Aug 13, 2020
@govi20
Copy link
Contributor

govi20 commented Aug 13, 2020

Hi, I would like to give it a shot.

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 13, 2020

You're welcome @govi20.

@mp911de mp911de added the status: in-progress An issue that is currently being worked on label Aug 13, 2020
@govi20
Copy link
Contributor

govi20 commented Aug 13, 2020

@mp911de Thanks, Mark. How do I test it? could you please explain so that I can write test cases.

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 13, 2020

Take a look at an earlier comment: #301 (comment). Let me know if that helps or your need further guidance. Happy to help.

@uazw
Copy link

uazw commented Aug 13, 2020

Hi, I just raise a pr based on the conversion, can you please have a look?

@nefsir
Copy link

nefsir commented Aug 14, 2020

Hi! I have same issue using HStore data type. Both AbstractTemporalCodec and AbstractNumericCodec need to return false instead throwing an exception.

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 14, 2020

@uazw this is a bit unfortunate as @govi20 claimed to work on the issue and it would not be fair towards @govi20 who wanted to spend time.

@uazw
Copy link

uazw commented Aug 14, 2020

@mp911de sure thing! let me close my pr first, and looking for others issues.

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 14, 2020

Let's wait for a response from @govi20 before we proceed.

@hvicha
Copy link

hvicha commented Aug 18, 2020

Hello All, there is same bug in AbstractNumericCodec.canDecode(…)

@govi20
Copy link
Contributor

govi20 commented Aug 18, 2020

Thanks for pointing it out. Fixed it locally. @mp911de Should I push it on the same branch?

@mp911de
Copy link
Collaborator Author

mp911de commented Aug 18, 2020

Yes, please. Please also note that I'll be back on Aug 31.

mp911de pushed a commit that referenced this issue Sep 7, 2020
…om type object.

* #301 Fix temporal code canDecode custom object issue

* #301 address review comment

* #301 handle custom types in NumbericCodec canDecode

[closes #301][#317]
mp911de pushed a commit that referenced this issue Sep 7, 2020
…om type object.

* #301 Fix temporal code canDecode custom object issue

* #301 address review comment

* #301 handle custom types in NumbericCodec canDecode

[closes #301][#317]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: first-timers-only An issue that can only be worked on by brand new contributors status: in-progress An issue that is currently being worked on type: bug A general bug
Projects
None yet
6 participants