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 ActiveJob arguments serialization to correctly serialize String subclasses having custom serializers #50090

Merged

Conversation

fatkodima
Copy link
Member

Fixes #50076 (look there for a lengthy discussion).

Should we also raise a deprecation warning for String subclasses without custom serializers? It worked before this change.

cc @byroot

@rails-bot rails-bot bot added the activejob label Nov 17, 2023
@@ -72,8 +72,14 @@ def deserialize(arguments)

def serialize_argument(argument)
case argument
when *PERMITTED_TYPES
Copy link
Member

Choose a reason for hiding this comment

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

PERMITTED_TYPES is now only used in deserialize_argument, perhaps we can get rid of it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, deleted.

…ubclasses having custom serializers

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
@fatkodima fatkodima force-pushed the fix-active_job-serialization-string-subclasses branch from 59aa462 to 14578ea Compare November 17, 2023 23:55
@byroot byroot merged commit 438cad4 into rails:main Nov 18, 2023
4 checks passed
@fatkodima fatkodima deleted the fix-active_job-serialization-string-subclasses branch November 18, 2023 00:11
octokatherine added a commit to octokatherine/rails that referenced this pull request Nov 20, 2023
rails#50090 broke serialization of String
subclasses that don't have serializers, like ActiveSupport::SafeBuffer.

Co-authored-by: John Hawthorn <john@hawthorn.email>
jarenas9539 added a commit to jarenas9539/rails that referenced this pull request Nov 21, 2023
… of String

After changes from rails#50090 and rails#50122, a redundant if statement remains on Arguments#serialize on String related classes serialization. When adding the begin/rescue statement on the else clause the if clause began to be scoped on the rescue clause as StringSerializer is not defined and will throw SerializationError. As if clause and rescue clause share same result, the if clause started to be redundant.
byroot added a commit that referenced this pull request Dec 2, 2023
…-string-subclasses

Fix ActiveJob arguments serialization to correctly serialize String subclasses having custom serializers
@byroot
Copy link
Member

byroot commented Dec 2, 2023

Backported to 7-1-stable as 49ac7e5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect serialization of ActiveSupport::StringInquirer instances
2 participants