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 serialization of replies when some of them are URIs #13957

Merged

Conversation

ClearlyClaire
Copy link
Contributor

Fixes #13956

This happens because Active Model Serializer's CollectionSerializer (automatically used for arrays) does not allow mixing primitives (such as strings, like the URIs here) and raises :no_serializer whenever one of the items is a primitive, making the whole thing fall back to to_json.

This PR introduces a StringSerializer to allow mixing strings with serializable objects. This messes a bit with the fact that AMS serializers are geared towards rendering actual JSON object, but that was already the case of the built-in ActiveModel::Serializer::CollectionSerializer.

@ClearlyClaire ClearlyClaire force-pushed the fixes/mix-uri-inlined-objects branch 5 times, most recently from e055c2a to 0dccf04 Compare June 4, 2020 15:19
@Gargron Gargron merged commit aed3a43 into mastodon:master Jun 4, 2020
shouo1987 pushed a commit to CrossGate-Pawoo/mastodon that referenced this pull request Dec 7, 2022
* Fix serialization of replies when some of them are URIs

Fixes mastodon#13956

* Add test
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.

Invalid JSON in CollectionPage
2 participants