Take into account a CollectionPage decoded as array#32
Open
j3j5 wants to merge 1 commit intolandrok:masterfrom
Open
Take into account a CollectionPage decoded as array#32j3j5 wants to merge 1 commit intolandrok:masterfrom
j3j5 wants to merge 1 commit intolandrok:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When trying this library, I was trying to create a custom type for Mastodon following the docs. I've added my own type to support
Noteobjects adding the missing properties but when I try to create aNoteobject with with of my own posts, I get the follwing TypeError:After some debugging I realized that when validating a
CollectionPage, first it validates that is a validCollection, which has a check in case the$itemis not an array, so it'll convert it to object, and then, check that the$itemhas thetypeOfproperty, but then is not doing the array-object conversion, hence the error.This patch fixes that.
Here's the json file that produces the error. Fails when validating the
firstkey. It's a json retrieved from Mastodon v4.0.2.{ "@context": [ "https://www.w3.org/ns/activitystreams", { "ostatus": "http://ostatus.org#", "atomUri": "ostatus:atomUri", "inReplyToAtomUri": "ostatus:inReplyToAtomUri", "conversation": "ostatus:conversation", "sensitive": "as:sensitive", "toot": "http://joinmastodon.org/ns#", "votersCount": "toot:votersCount", "Hashtag": "as:Hashtag" } ], "id": "https://hachyderm.io/users/j3j5/statuses/109321328485360034", "type": "Note", "summary": null, "inReplyTo": null, "published": "2022-11-10T20:11:31Z", "url": "https://hachyderm.io/@j3j5/109321328485360034", "attributedTo": "https://hachyderm.io/users/j3j5", "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "cc": [ "https://hachyderm.io/users/j3j5/followers" ], "sensitive": false, "atomUri": "https://hachyderm.io/users/j3j5/statuses/109321328485360034", "inReplyToAtomUri": null, "conversation": "tag:hachyderm.io,2022-11-10:objectId=1050302:objectType=Conversation", "content": "\u003cp\u003eI\u0026#39;m buzzing with ideas on how to bring all my \u003ca href=\"https://hachyderm.io/tags/GoodBots\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eGoodBots\u003c/span\u003e\u003c/a\u003e into the fediverse but this week I don\u0026#39;t have energy at the end of the day to implement any of them. Luckily the weekend is close 🙏 \u003ca href=\"https://hachyderm.io/tags/StayTuned\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eStayTuned\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e", "contentMap": { "en": "\u003cp\u003eI\u0026#39;m buzzing with ideas on how to bring all my \u003ca href=\"https://hachyderm.io/tags/GoodBots\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eGoodBots\u003c/span\u003e\u003c/a\u003e into the fediverse but this week I don\u0026#39;t have energy at the end of the day to implement any of them. Luckily the weekend is close 🙏 \u003ca href=\"https://hachyderm.io/tags/StayTuned\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eStayTuned\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e" }, "attachment": [], "tag": [ { "type": "Hashtag", "href": "https://hachyderm.io/tags/GoodBots", "name": "#GoodBots" }, { "type": "Hashtag", "href": "https://hachyderm.io/tags/staytuned", "name": "#staytuned" } ], "replies": { "id": "https://hachyderm.io/users/j3j5/statuses/109321328485360034/replies", "type": "Collection", "first": { "type": "CollectionPage", "next": "https://hachyderm.io/users/j3j5/statuses/109321328485360034/replies?min_id=109321387340611540\u0026page=true", "partOf": "https://hachyderm.io/users/j3j5/statuses/109321328485360034/replies", "items": [ "https://hachyderm.io/users/j3j5/statuses/109321387340611540" ] } } }