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

uSync imports Content with id=0 #225

Closed
bogdanvista opened this issue Apr 1, 2024 · 5 comments
Closed

uSync imports Content with id=0 #225

bogdanvista opened this issue Apr 1, 2024 · 5 comments

Comments

@bogdanvista
Copy link

Describe the bug
I was trying to import some content and fell in a rabbit hole... All documents are imported with the ID=0 so they don't show up at all...

image

I thought maybe my DB was broken so I started from scratch and nothing imports on a new DB.
I can leave you a .config content file:

<?xml version="1.0" encoding="utf-8"?>
<Content Key="4a80fe82-c7c6-42cc-a86f-e4b197dc955f" Alias="Root" Level="1">
  <Info>
    <Parent Key="00000000-0000-0000-0000-000000000000"></Parent>
    <Path>/Root</Path>
    <Trashed>false</Trashed>
    <ContentType>root</ContentType>
    <CreateDate>2021-07-21T12:53:42</CreateDate>
    <NodeName Default="Root" />
    <SortOrder>0</SortOrder>
    <Published Default="true" />
    <Schedule />
    <Template Key="43a19672-d071-4d24-a115-6e78dd4ff98d">Root</Template>
  </Info>
  <Properties>
    <gridContent>
      <Value><![CDATA[{
  "name": "1 column layout",
  "sections": [
    {
      "grid": "12",
      "rows": []
    }
  ]
}]]></Value>
    </gridContent>
  </Properties>
</Content>

Is there anything wrong with the file?
Sometimes there was an error with "cannot save a non-current version". So maybe that's a clue.

Any ideas? The content files are not from the latest version of usync but when I saved something there was no difference...
Maybe something that happened in the latest versions of uSync?

Thanks in advance.

Version (please complete the following information):

  • Umbraco Version: 13.2.0
  • uSync Version 13.1.3
  • uSync.Complete Version 13.1.3
@bogdanvista
Copy link
Author

It seems like if some content fails to import then nothing will get imported.
From hundreds of content files, a few were failing to import... then Umbraco would get in a certain state... if you imported again (without a apppool recycle) you would get "cannot save a non-current version" on more content files. Somehow the content existed in cache... If I tracked down an id from the import logs.. and then added that to the CMS url (/umbraco#/content/content/edit/XXXX) then it would show... but there was nothing in the tree... I assume it lived in the cache as this behavior would disappear after an app pool recycle.

I've clean up the Content folder and reexported everything then all can be imported.

Still, I find it weird that one broken piece of content .config can prevent anything from importing.

@KevinJump
Copy link
Member

Hi,

Yes very odd indeed, do you have a copy of the uSync folder that was doing this on a clean install ? i would like to take a look see if there is anything.

there are lots of caching and notifications and scopes involved when importing and maybe something gets mixed up and we can do something,

the content version thing does look like something that can happen if content is changed during a saved or published notification (e.g something listening for a save notifcation itself changes content and then saves causing another notification to happen).

uSync (v13) will also batch notifications together and in fact they can get processed in the background. this means if you have custom notifications you have to be aware of this, there can be side effects (https://docs.jumoo.co.uk/usync/uSync/guides/background)

N.B this is false by default - but the notifications do still happen in bullk (but not in the background) after a load of items have been imported .

@bogdanvista
Copy link
Author

Hello,

I managed to create a uSync subset that reproduces this (I hope). There's also a missing doctype definition, but also the error with the non-current document.
image

I think it should still import something regardless...

I'll send the uSync folder to info@jumoo.co.uk, is that fine? I feel it's better than posting it publicly (even though I don't think there's anything sensitive there).

@KevinJump
Copy link
Member

Hi,

I've taken a look and its looks the root of the issue is caused because your uSync folder has clashing key value in it. (e.g more than one content item file with the same Key (guid) value.

you can see this if you run the uSync health check.

image

the way the error is surfacing is a little odd as we introduced a new feature in v13.1 that can merge content files together from multiple folders (roots) - but in this instance what happens is it attempts to merge together two duplicates in the same usync "folder" (e.g usync/v9/content....). when really we should throw an error.

we don't do the health check duplicate check on sync because if there are lots of files it can take a while, and would slow down all uSync operations,

but what we can do is throw an error if during the sync process we find a duplicate key in the folder we are looking into, so we've added that and will put it in the next release.

image

--
in the meantime, if you run the health check, you can find the duplicate files and manually fix them (as long as they don't have children, just changing the key value in the .config will do it.

duplicates like this shouldn't be possible to create on a single Umbraco install. as uSync will always clean up duplicate files on save of a file with a key., but they can occur if source code check-ins don't contain all the changes uSync makes, or if uSync config files are copied around the uSync folder manually - the only option then is to clean them up by hand, but the health check does help you spot them

KevinJump added a commit to KevinJump/uSync that referenced this issue Apr 9, 2024
@bogdanvista
Copy link
Author

Hello,

Thank you for investigating, nice to see you found the issue and a fix.

I didn't know about the health check, never used it before, but good that I learned about that.

Yeah, I'm sure this scenario doesn't normally happen but since there are a few people working on the same project, with uSync being shared in source control, funky stuff is bound to happen.

Thanks again.

KevinJump added a commit to KevinJump/uSync that referenced this issue Apr 17, 2024
KevinJump added a commit to KevinJump/uSync that referenced this issue Apr 17, 2024
* From v13: Fixes (#590) - missing null check

* From v13: Fixes #604. don't prepend path with ~ (for no random reason!)

* From v13: Fix #224 - Observe root folder value in rootfolder array if set (and root folders array is not set). (#606)

* From v13: Throw for duplicates ( Jumoo/uSync.Complete.Issues#225 )

* Add serializers and handlers for webhooks. (#613)

* Add serializers and handlers for webhooks.

* Webhook Comments

* From v13: Add serializers and handlers for webhooks. (#613)

* From v13: Fix #609 Default language importing. (#614)

* From v13: Use folders provided in options over config (#610)

* From v13: fix #605 - check delete by serializing item one last time. (#616)

* From v13: Fix - delete entries show up twice in report and actions. (#617)

* From v13: #612 - couple of extra checks so we never try to create an XCData section with a null value. (#618)

* Fix for #619. don't report property deletes as changes when they have… (#621)

* Fix for #619. don't report property deletes as changes when they have already happened

* Add fix for #620 - don't recreate items that are deleted.

* v13 - > v14 null checks.

* From v13: DataType merging Empty items alway win

* update build script

* tidy up logging.

* consistant JSON options

* Add Extra saves for content (not sure we need them! - might be a rc1 issue)

* Add Ability to change the editor alias on import

* Post RC1 - migration fixes.

* chore: project things
KevinJump added a commit to KevinJump/uSync that referenced this issue Apr 19, 2024
* From v13: Fixes (#590) - missing null check

* From v13: Fixes #604. don't prepend path with ~ (for no random reason!)

* From v13: Fix #224 - Observe root folder value in rootfolder array if set (and root folders array is not set). (#606)

* From v13: Throw for duplicates ( Jumoo/uSync.Complete.Issues#225 )

* Add serializers and handlers for webhooks. (#613)

* Add serializers and handlers for webhooks.

* Webhook Comments

* From v13: Add serializers and handlers for webhooks. (#613)

* From v13: Fix #609 Default language importing. (#614)

* From v13: Use folders provided in options over config (#610)

* From v13: fix #605 - check delete by serializing item one last time. (#616)

* From v13: Fix - delete entries show up twice in report and actions. (#617)

* From v13: #612 - couple of extra checks so we never try to create an XCData section with a null value. (#618)

* Fix for #619. don't report property deletes as changes when they have… (#621)

* Fix for #619. don't report property deletes as changes when they have already happened

* Add fix for #620 - don't recreate items that are deleted.

* v13 - > v14 null checks.

* From v13: DataType merging Empty items alway win

* update build script

* tidy up logging.

* consistant JSON options

* Add Extra saves for content (not sure we need them! - might be a rc1 issue)

* Add Ability to change the editor alias on import

* Post RC1 - migration fixes.

* chore: project things

* fixes #629 have a custom Operations handler just for uSync swagger endpoint.
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