I get an import fail error when importing media. Content and templates etc are imported perfectly.
Umbraco version is 8.18.6
uSync v8.11.4 + Content Edition v8.11.4
Error:
Import Fail: Value cannot be null. Parameter name: value
In the logs i have:
{"@t":"2023-04-16T09:34:12.9234475Z","@mt":"{alias}: Import Failed : {exception}","@l":"Warning","alias":"mediaHandler","exception":"System.ArgumentNullException: Value cannot be null.\r\nParameter name: value\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n at WebApp.Infrastructure.Services.MediaLibraryService.ReSizeImage(IMedia media)\r\n at WebApp.Infrastructure.Composers.ApplicationComponent.MediaService_Saving(IMediaService sender, SaveEventArgs1 e)\r\n at Umbraco.Core.Events.TypedEventHandler2.Invoke(TSender sender, TEventArgs e)\r\n at Umbraco.Core.Events.QueuingEventDispatcherBase.DispatchCancelable[TSender,TArgs](TypedEventHandler2 eventHandler, TSender sender, TArgs args, String eventName)\r\n at Umbraco.Core.Services.Implement.MediaService.Save(IMedia media, Int32 userId, Boolean raiseEvents)\r\n at uSync8.ContentEdition.Serializers.MediaSerializer.SaveItem(IMedia item)\r\n at uSync8.Core.Serialization.SyncSerializerRoot1.Deserialize(XElement node, SyncSerializerOptions options)\r\n at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot2.DeserializeItem(XElement node, SyncSerializerOptions options)\r\n at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot2.ImportElement(XElement node, String filename, HandlerSettings settings, uSyncImportOptions options)","SourceContext":"uSync8.ContentEdition.Handlers.MediaHandler","ProcessId":13332,"ProcessName":"w3wp","ThreadId":204,"AppDomainId":11,"AppDomainAppId":"LMW3SVC29ROOT","MachineName":"SMERTLING","Log4NetLevel":"WARN ","HttpRequestNumber":3,"HttpRequestId":"2b3e342e-f596-41ac-bcf9-c92e8e023beb"}
Media Import fail in uSync 8.11.4
Hi
I get an import fail error when importing media. Content and templates etc are imported perfectly.
Umbraco version is 8.18.6 uSync v8.11.4 + Content Edition v8.11.4
Error: Import Fail: Value cannot be null. Parameter name: value
In the logs i have: {"@t":"2023-04-16T09:34:12.9234475Z","@mt":"{alias}: Import Failed : {exception}","@l":"Warning","alias":"mediaHandler","exception":"System.ArgumentNullException: Value cannot be null.\r\nParameter name: value\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n at WebApp.Infrastructure.Services.MediaLibraryService.ReSizeImage(IMedia media)\r\n at WebApp.Infrastructure.Composers.ApplicationComponent.MediaService_Saving(IMediaService sender, SaveEventArgs
1 e)\r\n at Umbraco.Core.Events.TypedEventHandler
2.Invoke(TSender sender, TEventArgs e)\r\n at Umbraco.Core.Events.QueuingEventDispatcherBase.DispatchCancelable[TSender,TArgs](TypedEventHandler2 eventHandler, TSender sender, TArgs args, String eventName)\r\n at Umbraco.Core.Services.Implement.MediaService.Save(IMedia media, Int32 userId, Boolean raiseEvents)\r\n at uSync8.ContentEdition.Serializers.MediaSerializer.SaveItem(IMedia item)\r\n at uSync8.Core.Serialization.SyncSerializerRoot
1.Deserialize(XElement node, SyncSerializerOptions options)\r\n at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot2.DeserializeItem(XElement node, SyncSerializerOptions options)\r\n at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot
2.ImportElement(XElement node, String filename, HandlerSettings settings, uSyncImportOptions options)","SourceContext":"uSync8.ContentEdition.Handlers.MediaHandler","ProcessId":13332,"ProcessName":"w3wp","ThreadId":204,"AppDomainId":11,"AppDomainAppId":"LMW3SVC29ROOT","MachineName":"SMERTLING","Log4NetLevel":"WARN ","HttpRequestNumber":3,"HttpRequestId":"2b3e342e-f596-41ac-bcf9-c92e8e023beb"}Example of media config file:
<?xml version="1.0" encoding="utf-8"?> <Media Key="02f20201-3a28-4fdf-9ee8-2c12516b2c67" Alias="2 østers" Level="2"> <Info> <Parent Key="a8f4971c-ede7-40a7-aedc-7d330d62056f">Tekst bileder</Parent> <Path>/TekstBileder/osters</Path> <Trashed>false</Trashed> <ContentType>Image</ContentType> <CreateDate>2023-04-10T17:20:13</CreateDate> <NodeName Default="2 østers" /> <SortOrder>4</SortOrder> </Info> <Properties> <umbracoFile> <Value><![CDATA[{"src":"/media/a2bpeari/img_3009-1.jpg"}]]></Value> </umbracoFile> </Properties> </Media>
(Above example is HTML escaped as I could not show XML in code tags...)
I hope someone can help. Thanks in advance
/Rasmus
Hi,
It looks like the error is coming from some custom code you have? WebApp.Infrastructure.Services.MediaLibraryService.ReSizeImage
Looks like that method is being fired when a media item is saved and is trying to deseralize the JSON in an image?
This isn't always JSON (it depends on what mediatypenan time is) or the JSON might have some things not set.
Guessing that isn't being caught in your custom code?
Hi Kevin,
That was spot on. It works perfectly now thanks :)
Rasmus
is working on a reply...