Jumoo / uSyncMigrations

Rough and ready migration code.
Mozilla Public License 2.0
47 stars 62 forks source link

Errors Parsing the Config Data #122

Open markadrake opened 1 year ago

markadrake commented 1 year ago

Reference:

  • uSync 10.3.1.-beta001
  • uSync.Migrations 4.0.0-phase.2.1

Hi Everyone,

I'm running into an issue with this file, and potentially others after it, where the parsing seems to blow up.

image

Newtonsoft.Json.JsonReaderException: After parsing a value an unexpected character was encountered: 1. Path '[0].link', line 4, position 14.
   at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments)
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at uSync.Migrations.Migrators.RelatedLinksMigrator.GetContentValue(SyncMigrationContentProperty contentProperty, SyncMigrationContext context)
   at uSync.Migrations.Handlers.Shared.SharedContentBaseHandler`1.MigrateContentValue(SyncMigrationContentProperty migrationProperty, SyncMigrationContext context)
   at uSync.Migrations.Handlers.Shared.SharedContentBaseHandler`1.ConvertPropertyValue(String itemType, String contentType, XElement property, SyncMigrationContext context)
   at uSync.Migrations.Handlers.Shared.SharedContentBaseHandler`1.MigrateFile(XElement source, Int32 level, SyncMigrationContext context)
   at uSync.Migrations.Handlers.MigrationHandlerBase`1.MigrateFolder(String folder, Int32 level, SyncMigrationContext context)

I believe the error is being reported with the very first link property:

  {
    "caption": "Credit Reports",
    "link": "18d02d55-6aa5-4689-b980-2ba3238658cd", // HERE
    "newWindow": false,
    "internal": "18d02d55-6aa5-4689-b980-2ba3238658cd",
    "edit": false,
    "isInternal": true,
    "internalName": "Credit Reports",
    "type": "internal",
    "title": "Credit Reports"
  },

I validated the JSON below in an external validator, just in case there was something my eyes didn't see. The JSON came back valid. Here is the entire config file for reference:

<?xml version="1.0" encoding="utf-8"?>
<membersOnlyHeaderShortcut guid="89a3cde2-c885-4f23-895e-4d6e4bd4b605" id="4063" nodeName="Reports" isDoc="" updated="2018-01-21T15:29:45.0270000Z" parentGUID="eba0bf09-2c38-4387-bc4c-bebc79a84595" nodeTypeAlias="membersOnlyHeaderShortcut" templateAlias="" sortOrder="1" published="true" isBlueprint="false">
  <commentToFirstApprover></commentToFirstApprover>
  <excludeFromSitemap>0</excludeFromSitemap>
  <excludeFromSiteSearch>0</excludeFromSiteSearch>
  <firstApprover><![CDATA[[
  6
]]]></firstApprover>
  <hasRunningWorkflow><![CDATA[No]]></hasRunningWorkflow>
  <links><![CDATA[[
  {
    "caption": "Credit Reports",
    "link": "18d02d55-6aa5-4689-b980-2ba3238658cd",
    "newWindow": false,
    "internal": "18d02d55-6aa5-4689-b980-2ba3238658cd",
    "edit": false,
    "isInternal": true,
    "internalName": "Credit Reports",
    "type": "internal",
    "title": "Credit Reports"
  },
  {
    "caption": "Deposit Reports",
    "link": "66473c23-240e-42f4-a6e9-afe112a4abef",
    "newWindow": false,
    "internal": "66473c23-240e-42f4-a6e9-afe112a4abef",
    "edit": false,
    "isInternal": true,
    "internalName": "Demand Deposit Reports",
    "type": "internal",
    "title": "Deposit Reports"
  },
  {
    "caption": "Safekeeping Reports",
    "link": "e4b9c55c-60ab-4a18-ac59-cb12ac7e780c",
    "newWindow": false,
    "internal": "e4b9c55c-60ab-4a18-ac59-cb12ac7e780c",
    "edit": false,
    "isInternal": true,
    "internalName": "Safekeeping/Pledge Reports",
    "type": "internal",
    "title": "Safekeeping Reports"
  },
  {
    "caption": "Funds Transfer Reports",
    "link": "d199b112-a54e-4a1d-863f-9a489cd7eb61",
    "newWindow": false,
    "internal": "d199b112-a54e-4a1d-863f-9a489cd7eb61",
    "edit": false,
    "isInternal": true,
    "internalName": "Funds Transfer Reports",
    "type": "internal",
    "title": "Funds Transfer Reports"
  },
  {
    "caption": "Capital Stock Reports",
    "link": "d23cdbce-106d-4408-9da7-7bdce4f5a83b",
    "newWindow": false,
    "internal": "d23cdbce-106d-4408-9da7-7bdce4f5a83b",
    "edit": false,
    "isInternal": true,
    "internalName": "Your Stock",
    "type": "internal",
    "title": "Capital Stock Reports"
  },
  {
    "caption": "All Reports",
    "link": "bffdb065-fa6c-4155-bd29-b23202d9b49c",
    "newWindow": false,
    "internal": "bffdb065-fa6c-4155-bd29-b23202d9b49c",
    "edit": false,
    "isInternal": true,
    "internalName": "All reports",
    "type": "internal",
    "title": "All Reports"
  },
  {
    "caption": "Set Up Report Bundles",
    "link": "fdfb70fc-7580-4425-bdfa-913b95630391",
    "newWindow": false,
    "internal": "fdfb70fc-7580-4425-bdfa-913b95630391",
    "edit": false,
    "isInternal": true,
    "internalName": "Report bundles",
    "type": "internal",
    "title": "Set Up Report Bundles"
  }
]]]></links>
  <metadataDescription></metadataDescription>
  <publishAt></publishAt>
  <umbracoUrlAlias></umbracoUrlAlias>
  <unPublishAt></unPublishAt>
  <workflowHistory></workflowHistory>
</membersOnlyHeaderShortcut>

Any help would be appreciated. I'm not sure how to debug this.

KevinJump commented 1 year ago

Hi,

first might be worth updating to latest version. @marcemarc did something recently for the wrapping of the GUID values in relatedLinks - https://github.com/Jumoo/uSyncMigrations/commit/6ca9c86ad8b74bddd44f9f0af9b59e2b9d08ead1

I suspect that's your issue.

if not i would take a look at the RelatedLinksMigrator - because i suspect the issue is here (& this might well be the fix)

markadrake commented 1 year ago

Oh I see. This is a bit confusing.

A month ago, or longer, I noticed that my config files did not have quotes around guid keys. I had to do a search and replace to put them there.

My latest export from v7 resulted in config files that have quotes around the guids.

I'll double check I'm using the latest versions of uSync. To confirm - I am still using uSync 10.3.1.-beta001 and uSync.Migrations 4.0.0-phase.2.1.

KevinJump commented 1 year ago

I wonder if that means the fix is double wrapping them. 🤔

markadrake commented 1 year ago

Sorry for the live troubleshooting and updates Kevin.

Looking at a fresh export of Umbraco v7 content, I can find both cases:

I've even found this to happen within the same file / property / array. Quite strange how it's inconsistent.

KevinJump commented 1 year ago

Sort of hoping PR #123 will fix this - it will remove double quotes - which i think is what happens when a quoted GUID is matched.

I am sure there is a clever RegEx for it, but in 6 months i wouldn't be able to understand what it did, this way we can see what hack we are fixing.