[SOLVED] Cloning app using CLI doesn't work for components

Hi Sebastian,

I’ve previously cloned apps myself using the CLI (export app to folder, sync to new app), but now that I’ve added components to my app the process no longer works.

The problem is that the sync process adds my components as schemas in the new app, not as components.

I’ve tried creating empty components (with the same names) in the new app before the sync, but then the components have new ids which messes up the sync process.

Is there some step I’m missing?

Best,

Barton

Could be a bug, but can you check first, whether the stored components in the file system have a “type”: “Component”?

I just did a fresh “sync out” and checked the JSON for one of my components. It does indeed include this line:

“schemaType”: “Component”

I decided to try “sync in”. You’ll see in this log from my command window that there are a couple of CLI “failed: Validation error” messages at the bottom:

https://drive.google.com/file/d/1QxGQl6OR0oGMkE1CSw9aq48RFgo2nefp/view?usp=sharing

I checked the new app (dev2-daariz-english0-course) and found that all schemas are under the “schemas” heading, including some components.

I have fixed it. It was a pure CLI issue and a new version is deployed.

Hi Sebastian,

I installed the new version of the CLI and gave it a try. Now the components show up in the right place, which is great.

But I’m getting these two error on the “importing assets” phase:

Upserting #50… failed: OBJECT_NOTFOUND.
Upserting #34… failed: OBJECT_NOTFOUND.

And these two errors on the “importing contents” phase:

Upserting #0… failed: Validation error: sections.iv: Invalid component. Cannot find schema.
Upserting #0… failed: Validation error: sections.iv: Invalid component. Cannot find schema.

There are two files missing from assets in the new app, and missing content as well.

How can we diagnose this further?

Best,

Barton

I have to test it again. I have an idea.

Okay, thanks. Standing by.

I have pushed another fix.

Sorry, I have not read you second report carefully. Yes, I understand the bug now. The exported content still have the old schemas.

I have a new version: v7.23…sync out and sync in is needed.

I just tried the new version. The contents came through fine this time!

But I’m still getting the “failed: OBJECT_NOTFOUND” error twice, and there are two missing assets.

I’ll send you a link to my exported files in a DM.

-Barton

We should focus on one thing at a time. In this case the problem seems to be assets.

I hope I have fixed the asset problem this time as well. Sorry for all the hustle and thanks for testing it.

This time the “sync in” seemed to get past the asset import without errors. But then I got the following error:

  • STEP 1 of 6: Importing Schemas started

ERROR: HTTP Response:

{“message”:“Forbidden”,“traceId”:“00-5cacf99573a46878e2c848234c9bf343-dc44440a179d345e-01”,“type”:“https://tools.ietf.org/html/rfc7231#section-6.5.3","statusCode”:403}

Squidex.ClientLibrary.Management.SquidexManagementException: The HTTP status code of the response was not expected (403).

Status: 403
Response:
{“message”:“Forbidden”,“traceId”:“00-5cacf99573a46878e2c848234c9bf343-dc44440a179d345e-01”,“type”:“https://tools.ietf.org/html/rfc7231#section-6.5.3","statusCode”:403}
at Squidex.ClientLibrary.Management.SchemasClient.GetSchemasAsync(String app, CancellationToken cancellationToken)
at Squidex.CLI.Commands.Implementation.Sync.Schemas.SchemasSynchronizer.ImportAsync(ISyncService sync, SyncOptions options, ISession session)
at Squidex.CLI.Commands.Implementation.Sync.Synchronizer.<>c__DisplayClass5_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Squidex.CLI.Commands.Implementation.Extensions.Foreach[T](IEnumerable1 source, Func3 action)
at Squidex.CLI.Commands.Implementation.Sync.Synchronizer.ImportAsync(String path, SyncOptions options, ISession session)
at Squidex.CLI.Commands.App.Sync.In(InArguments arguments)
at CommandDotNet.Execution.InvocationResultExtensions.GetResultCodeAsync(Object value)
at CommandDotNet.AppRunner.HandleException(Exception ex, IConsole console, CommandContext commandContext)
at CommandDotNet.AppRunner.Run(String[] args)
at Squidex.CLI.Program.Main(String[] args)

This can happen if the CLI client changes its own permission during sync. Perhaps we should skip that

Hmm. I’m not sure what you mean by, “perhaps we should skip that”.

Do you think the latest error would be resolved if I run the CLI in an administrator command prompt window?

What I meant: If the client is connected to an app with a client XYZ and this client XYZ is changed during to sync process to another role it might happen that client does not have the necessary permissions anymore for the rest of the sync process.

It turns out that the prior error was due to the fact that I forgot to give the new client I created in the new app owner rights.

However, when I tried it again (with a fresh new empty app), I got this error during the “importing assets” phase:

Uploading assets\files\0ffe7654-6c7d-…failed: System.IO.FileNotFoundException: Could not find file ‘C:\Data\Projects\Sahan\Squidex\eng0_export_2021-11-17\assets\files\0ffe7654-6c7d-422b-8cae-f795408d9a49.blob’.
File name: ‘C:\Data\Projects\Sahan\Squidex\eng0_export_2021-11-17\assets\files\0ffe7654-6c7d-422b-8cae-f795408d9a49.blob’
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileInfo.OpenRead()
at Squidex.CLI.Commands.Implementation.FileSystem.Default.DefaultFile.OpenRead()
at Squidex.CLI.Commands.Implementation.Sync.Assets.UploadPipeline.<>c__DisplayClass10_0.<<-ctor>b__1>d.MoveNext().

I’ll send you a message with a link to my export folder.

Have you made a new export with my last bugfix?