Skip to content

Fix serialization of replies when some of them are URIs#13957

Merged
Gargron merged 2 commits intomastodon:masterfrom
ClearlyClaire:fixes/mix-uri-inlined-objects
Jun 4, 2020
Merged

Fix serialization of replies when some of them are URIs#13957
Gargron merged 2 commits intomastodon:masterfrom
ClearlyClaire:fixes/mix-uri-inlined-objects

Conversation

@ClearlyClaire
Copy link
Copy Markdown
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
@ClearlyClaire ClearlyClaire force-pushed the fixes/mix-uri-inlined-objects branch from 0dccf04 to 0321019 Compare June 4, 2020 15:24
@ClearlyClaire ClearlyClaire requested a review from Gargron June 4, 2020 15:35
@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