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

Inconsistencies in deviation object format result in deserialization error #9

Open
AlexCSDev opened this issue Apr 7, 2024 · 3 comments

Comments

@AlexCSDev
Copy link

AlexCSDev commented Apr 7, 2024

Hello, while using DeviantArtFs.Api.Browse.PageNewestAsync method I have noticed that there is an inconsisency in returned deviation objects which results in the following error:

FSharp.Json.JsonDeserializationError: JSON Path: results[117].tier.stats. Failed to parse record from JSON that is not object.
   at FSharp.Json.Core.failDeserialization[a](JsonPath path, String message)
   at FSharp.Json.Core.deserializeRecord@463(JsonConfig config, JsonPath path, Type t, JsonValue jvalue)
   at FSharp.Json.Core.deserializeNonOption@322(JsonConfig config, JsonPath path, Type t, JsonField jsonField, JsonValue jvalue)
   at FSharp.Json.Core.deserializeUnwrapOption@376(JsonConfig config, JsonPath path, Type t, JsonField jsonField, FSharpOption`1 jvalue)
   at FSharp.Json.Core.deserializeRecord@463(JsonConfig config, JsonPath path, Type t, JsonValue jvalue)
   at FSharp.Json.Core.deserializeNonOption@322(JsonConfig config, JsonPath path, Type t, JsonField jsonField, JsonValue jvalue)
   at FSharp.Json.Core.deserializeUnwrapOption@376(JsonConfig config, JsonPath path, Type t, JsonField jsonField, FSharpOption`1 jvalue)
   at FSharp.Json.Core.deserializeRecord@463(JsonConfig config, JsonPath path, Type t, JsonValue jvalue)
   at FSharp.Json.Core.deserializeNonOption@322(JsonConfig config, JsonPath path, Type t, JsonField jsonField, JsonValue jvalue)
   at Microsoft.FSharp.Collections.ArrayModule.MapIndexed[T,TResult](FSharpFunc`2 mapping, T[] array) in D:\a\_work\1\s\src\FSharp.Core\array.fs:line 453
   at FSharp.Json.Core.deserializeList@420(JsonConfig config, JsonPath path, Type t, JsonValue jvalue)
   at FSharp.Json.Core.deserializeNonOption@322(JsonConfig config, JsonPath path, Type t, JsonField jsonField, JsonValue jvalue)
   at FSharp.Json.Core.deserializeRecord@463(JsonConfig config, JsonPath path, Type t, JsonValue jvalue)
   at FSharp.Json.Json.deserializeEx[T](JsonConfig config, String json)
   at DeviantArtFs.Utils.thenMap@100.MoveNext()

Here is the problematic tier object in question:

			"tier": {
				"state": "active",
				"is_user_subscribed": false,
				"can_user_subscribe": true,
				"subproductid": 569102470,
				"dollar_price": "5.00",
				"settings": {
					"access_settings": "all"
				},
				"stats": [],
				"benefits": [
					"Welcome Gift!",
					"Early Access to New Work",
					"Over 2k Resolution Images"
				]
			},

As you can see, despite documentation mentioning it can only be an object, for some reason they are returning array for stats and I guess that's why deserialization error is happening. I have also tested this with /deviation/#GUID# endpoint and it returns the same out of spec object, so this seems to be an issue in all of their api endpoints which return deviation object.

I'm not sure if you can do something about that, but I thought it's worth letting you know about this issue.

@IsaacSchemm
Copy link
Owner

IsaacSchemm commented Apr 14, 2024

Whatever serializer DeviantArt uses must (at least sometimes) render empty objects {} as empty arrays [] - I'm guessing whatever langauge they use on the backend doesn't distinguish between those two. I remember having an issue like that before.

I might just remove tier.stats from the model and add a note about it, unless you (or someone else) needs to use that for something.

@AlexCSDev
Copy link
Author

I don't particularly need that, so feel free to remove it if that's the easiest way of dealing with that.

@IsaacSchemm
Copy link
Owner

Should be fixed in https://www.nuget.org/packages/DeviantArtFs/9.1.1

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

No branches or pull requests

2 participants