You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if a property or block newly added to Notion is included in the response, a serializer exception is raised and the
The client will stop working.
Example:
Newtonsoft.Json.JsonSerializationException: 'Error converting value "{New property or block}" to type 'Notion.Client.PropertyValueType'
This is because there is no matching enum value for the type string, and the existing StringEnumConverter does not support returning a default value in such cases.
The existing code provides a class that accepts unsupported blocks called UnsupportedBlock, but this is effectively a non-functional state.
// Some other attributes
[JsonSubtypes.KnownSubTypeAttribute(typeof(UnsupportedBlock), BlockType.Unsupported)] <-- It will never be deserialized.
public interface IBlock : IObject, IObjectModificationData
{
[JsonProperty("type")]
[JsonConverter(typeof(StringEnumConverter))] <-- Cannot return default value if enum value does not exist
BlockType Type { get; set; }
[JsonProperty("has_children")]
bool HasChildren { get; set; }
[JsonProperty("in_trash")]
bool InTrash { get; set; }
[JsonProperty("parent")]
IBlockParent Parent { get; set; }
}
public enum BlockType
{
// Some other Type values
[EnumMember(Value = "unsupported")] <-- Newly added block type values are never "unsupported".
Unsupported
}
This problem could be remedied by creating a custom converter that returns a default value (i.e., "UnSupported") if the type string does not match and defining it on the enum side.
Property and PropertyValue also raise the same exception, so it may be necessary to create UnSupportedProperty and UnSupportedPropertyValue in a similar manner.
The text was updated successfully, but these errors were encountered:
Description
Currently, if a property or block newly added to Notion is included in the response, a serializer exception is raised and the
The client will stop working.
Example:
Newtonsoft.Json.JsonSerializationException: 'Error converting value "{New property or block}" to type 'Notion.Client.PropertyValueType'
This is because there is no matching enum value for the type string, and the existing StringEnumConverter does not support returning a default value in such cases.
The existing code provides a class that accepts unsupported blocks called UnsupportedBlock, but this is effectively a non-functional state.
This problem could be remedied by creating a custom converter that returns a default value (i.e., "UnSupported") if the type string does not match and defining it on the enum side.
Property and PropertyValue also raise the same exception, so it may be necessary to create UnSupportedProperty and UnSupportedPropertyValue in a similar manner.
The text was updated successfully, but these errors were encountered: