Skip to content

Fix double-encoding of non-string JSON values in nested blocks and add SingleBlock mapper - #955

Merged
KevinJump merged 2 commits into
Jumoo:v17/mainfrom
koty10:fix/single-block-value-corruption
May 13, 2026
Merged

KevinJump merged 2 commits into
Jumoo:v17/mainfrom
koty10:fix/single-block-value-corruption

Conversation

@koty10

@koty10 koty10 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Fix: Double-encoding of non-string JSON values inside block properties during import + missing SingleBlock mapper

Problem

When importing content that contains nested block structures (e.g. a BlockGrid with an area containing items that have SingleBlock properties with DropDown.Flexible fields), non-string JSON values get corrupted during import.

For example, a dropdown value ["Orange"] (a JSON array) is correctly stored in the serialized XML, but after import it becomes the JSON string "[\"Orange\"]" (double-encoded). This causes JsonReaderException errors when rendering the page and shows invalid values in the backoffice.

Root cause

SyncBlockMapperBase<T>.GetImportProperty() converts each block property value to a string via GetStringValue(), sends it through the mapper collection, and assigns the result back to BlockPropertyValue.Value. For editors without a dedicated mapper (e.g. Umbraco.DropDown.Flexible), the raw string is returned and assigned back. When the parent block is re-serialized via SerializeJsonString(), values that were originally JSON arrays/objects/numbers (but are now C# strings) get double-encoded.

The export side (GetExportProperty) already handles this correctly by converting the result back to a JsonNode:

return result.ConvertToJsonNode()?.ExpandAllJsonInToken() ?? result;

But the import side was missing this conversion.

Fix

  1. SyncBlockMapperBase.GetImportProperty() — When the original BlockPropertyValue.Value was a non-string JSON type (JsonElement with ValueKind of Array, Object, Number, etc.), the string result is now converted back to a JsonNode before being assigned back. This preserves the correct JSON type and prevents double-encoding. String-type values are left unchanged to avoid altering their type.

  2. New SingleBlockMapper — Added a mapper for Umbraco.SingleBlock (analogous to existing BlockListMapper and BlockGridMapper). Without this, properties inside SingleBlock editors were never recursively processed during import — UDIs in MultiUrlPickers, media references, etc. inside SingleBlock were not mapped, and the entire SingleBlock value was subject to the double-encoding issue.

Affected scenarios

Any property editor without a dedicated ISyncMapper that stores non-string JSON values (arrays, objects, numbers) inside any block type (BlockGrid, BlockList, SingleBlock). The most visible case is Umbraco.DropDown.Flexible which stores values as ["SelectedValue"].

How to reproduce

  1. Create a page with a BlockGrid containing blocks that have a SingleBlock field
  2. Inside the SingleBlock, add a block with a DropDown.Flexible property, select a value (e.g. "Orange")
  3. Export via uSync
  4. On a different instance (clean DB), import via uSync
  5. The dropdown value is corrupted — page rendering fails with JsonReaderException

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a double-encoding issue where non-string JSON values (e.g. ["Orange"] from Umbraco.DropDown.Flexible) inside nested block properties were being re-serialized as JSON strings on import, corrupting the value. It also introduces a missing SingleBlockMapper so that properties inside Umbraco.SingleBlock editors are recursively processed in the same way as BlockList and BlockGrid.

Changes:

  • In SyncBlockMapperBase.GetImportProperty, when the original value was a non-string JSON type, convert the mapped string result back to a JsonNode to preserve the original JSON shape.
  • Add a IsNonStringJsonValue helper that detects JsonElement (any ValueKind except String/Undefined) as well as JsonArray/JsonObject.
  • Add a new SingleBlockMapper registered via ISyncMapper discovery, mirroring BlockListMapper/BlockGridMapper but typed as SyncBlockMapperBase<SingleBlockValue>.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
uSync.Core/Mapping/SyncBlockMapperBase.cs Adds JSON-type preservation on the import path to avoid double-encoding non-string values.
uSync.Core/Mapping/Mappers/SingleBlockMapper.cs New mapper enabling recursive import/export processing of Umbraco.SingleBlock properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KevinJump

Copy link
Copy Markdown
Member

Hi Thanks for this, done some tests and it looks good 👍

  • i've just moved the static IsNonStringJsonValue into out JsonExtensions class, in case we want to use it somewhere else.

@KevinJump
KevinJump merged commit 0ba2e0c into Jumoo:v17/main May 13, 2026
3 checks passed
@koty10
koty10 deleted the fix/single-block-value-corruption branch May 13, 2026 13:23
@KevinJump

Copy link
Copy Markdown
Member

In release v17.3.2 - https://www.nuget.org/packages/uSync/17.3.2

alexsee pushed a commit to alexsee/umbraco-container that referenced this pull request May 21, 2026
Updated [uSync](https://github.com/KevinJump/uSync) from 17.3.0 to
17.3.2.

<details>
<summary>Release notes</summary>

_Sourced from [uSync's
releases](https://github.com/KevinJump/uSync/releases)._

## 17.3.2

This is a minor patch release of uSync for Umbraco v17, it contains
updates to how some values are encoded inside blocks and proper support
for SingleBlock elements.

## What's Changed
* Fix double-encoding of non-string JSON values in nested blocks and add
SingleBlock mapper by @​koty10 in
Jumoo/uSync#955

## New Contributors
* @​koty10 made their first contribution in
Jumoo/uSync#955

**Full Changelog**:
Jumoo/uSync@v17.3.1...v17.3.2

## 17.3.1

This is a Patch release for uSync for Umbraco v17.1. it contains fixes
and updates for known issues.:

the principle issue is uSync being to clever and trying to update the
EditorUIAlias based on best guess when in some situations (#​949) it
should just leave it alone

## What's Changed
* 👍 remove unused parameter on download, make it require admin at all
times (not just tree access) by @​KevinJump in
Jumoo/uSync#948
* 👍 update build script so we genete uSync.Extend now too. by
@​KevinJump in Jumoo/uSync#951
* 🐛 Fixes: #​949 - Property Editor UI alias values get overwritten on
import by @​KevinJump in Jumoo/uSync#950

**Full Changelog**:
Jumoo/uSync@v17.3.0...v17.3.1

### Installing
```
dotnet add package uSync --version 17.3.1
```

### Updating
> [NOTE!] with the new centralized package management feature being
using on v17.3+ umbraco projects you need to up date package versions
using dotnet package update, dotnet add package won't do it.

```
dotnet package update uSync --version 17.3.1
```

Commits viewable in [compare
view](Jumoo/uSync@v17.3.0...v17.3.2).
</details>

Updated [uSync.Complete](https://jumoo.co.uk/uSync/complete) from 17.3.2
to 17.3.6.

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@KevinJump KevinJump mentioned this pull request Jun 9, 2026
KevinJump added a commit that referenced this pull request Jun 9, 2026
* revert the encoding of blocks from #955 - because that breaks rendering as per #958

* Add Null checks to health check (cause it can load without the services).

* v17.3.4 - package files.
KevinJump added a commit that referenced this pull request Jun 12, 2026
* V17/image upload mapper (#959)

* update packages

* Split image upload and Image cropper mappers (to handle uploads in media slightly diffrently)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* add missing xml comments

* add debug , so we can see which mapper we hit.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* check on loading if the backoffice is there, if it's not we don't register anything for uSync. (only works on backoffice servers) (#962)

* V17/block encoding (#963)

* revert the encoding of blocks from #955 - because that breaks rendering as per #958

* Add Null checks to health check (cause it can load without the services).

* v17.3.4 - package files.

* Fix Jumoo/uSync.Complete.Issues#297 - write clean files even when folder has no children (so last items get deleted) (#964)

* update obsolete call to pagedChildren on content handler. (#965)

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
KevinJump added a commit that referenced this pull request Jun 12, 2026
* update tests project

* WIP - Element library (export/import)

* v18 element trackers

* Handling trashed state.

* Elements working tree.

* 18.0.0-rc2

* V17/merge 18 (#967)

* V17/image upload mapper (#959)

* update packages

* Split image upload and Image cropper mappers (to handle uploads in media slightly diffrently)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* add missing xml comments

* add debug , so we can see which mapper we hit.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* check on loading if the backoffice is there, if it's not we don't register anything for uSync. (only works on backoffice servers) (#962)

* V17/block encoding (#963)

* revert the encoding of blocks from #955 - because that breaks rendering as per #958

* Add Null checks to health check (cause it can load without the services).

* v17.3.4 - package files.

* Fix Jumoo/uSync.Complete.Issues#297 - write clean files even when folder has no children (so last items get deleted) (#964)

* update obsolete call to pagedChildren on content handler. (#965)

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
KevinJump added a commit that referenced this pull request Jun 19, 2026
* V17/image upload mapper (#959)

* update packages

* Split image upload and Image cropper mappers (to handle uploads in media slightly diffrently)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* add missing xml comments

* add debug , so we can see which mapper we hit.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* check on loading if the backoffice is there, if it's not we don't register anything for uSync. (only works on backoffice servers) (#962)

* V17/block encoding (#963)

* revert the encoding of blocks from #955 - because that breaks rendering as per #958

* Add Null checks to health check (cause it can load without the services).

* v17.3.4 - package files.

* Fix Jumoo/uSync.Complete.Issues#297 - write clean files even when folder has no children (so last items get deleted) (#964)

* update obsolete call to pagedChildren on content handler. (#965)

* Bump fast-uri in /uSync.Backoffice.Management.Client/usync-assets (#954)

Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](fastify/fast-uri@v3.1.0...v3.1.2)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump postcss in /uSync.Backoffice.Management.Client/usync-assets (#956)

Bumps [postcss](https://github.com/postcss/postcss) from 8.5.8 to 8.5.14.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](postcss/postcss@8.5.8...8.5.14)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump postcss from 8.5.8 to 8.5.14 in /uSync.History/history-client (#957)

Bumps [postcss](https://github.com/postcss/postcss) from 8.5.8 to 8.5.14.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](postcss/postcss@8.5.8...8.5.14)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump uuid and @umbraco-cms/backoffice in /uSync.History/history-client (#960)

Bumps [uuid](https://github.com/uuidjs/uuid) to 14.0.0 and updates ancestor dependency [@umbraco-cms/backoffice](https://github.com/umbraco/Umbraco-CMS). These dependencies need to be updated together.


Updates `uuid` from 13.0.0 to 14.0.0
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](uuidjs/uuid@v13.0.0...v14.0.0)

Updates `@umbraco-cms/backoffice` from 17.3.0 to 17.5.0-rc
- [Release notes](https://github.com/umbraco/Umbraco-CMS/releases)
- [Commits](umbraco/Umbraco-CMS@release-17.3.0...release-17.5.0-rc)

---
updated-dependencies:
- dependency-name: "@umbraco-cms/backoffice"
  dependency-version: 18.0.0-rc1
  dependency-type: direct:development
- dependency-name: uuid
  dependency-version: 14.0.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump vite from 8.0.5 to 8.0.16 in /uSync.History/history-client (#969)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.5 to 8.0.16.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.0.16/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.0.16
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump vite in /uSync.Backoffice.Management.Client/usync-assets (#970)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.5 to 8.0.16.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.0.16/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.0.16
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump markdown-it in /uSync.Backoffice.Management.Client/usync-assets (#971)

Bumps [markdown-it](https://github.com/markdown-it/markdown-it) from 14.1.1 to 14.2.0.
- [Changelog](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
- [Commits](markdown-it/markdown-it@14.1.1...14.2.0)

---
updated-dependencies:
- dependency-name: markdown-it
  dependency-version: 14.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump js-yaml and @hey-api/openapi-ts in /uSync.History/history-client (#974)

Removes [js-yaml](https://github.com/nodeca/js-yaml). It's no longer used after updating ancestor dependency [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts). These dependencies need to be updated together.


Removes `js-yaml`

Updates `@hey-api/openapi-ts` from 0.95.0 to 0.97.0
- [Release notes](https://github.com/hey-api/openapi-ts/releases)
- [Changelog](https://github.com/hey-api/hey-api/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hey-api/openapi-ts/compare/@hey-api/openapi-ts@0.95.0...@hey-api/openapi-ts@0.97.0)

---
updated-dependencies:
- dependency-name: "@hey-api/openapi-ts"
  dependency-version: 0.97.0
  dependency-type: direct:development
- dependency-name: js-yaml
  dependency-version:
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Swap renamed alias order to match (old, new) (#961)

merge

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jason Elkin <jasonelkin86@gmail.com>
KevinJump added a commit that referenced this pull request Jul 12, 2026
* V17/image upload mapper (#959)

* update packages

* Split image upload and Image cropper mappers (to handle uploads in media slightly diffrently)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* add missing xml comments

* add debug , so we can see which mapper we hit.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* check on loading if the backoffice is there, if it's not we don't register anything for uSync. (only works on backoffice servers) (#962)

* V17/block encoding (#963)

* revert the encoding of blocks from #955 - because that breaks rendering as per #958

* Add Null checks to health check (cause it can load without the services).

* v17.3.4 - package files.

* Fix Jumoo/uSync.Complete.Issues#297 - write clean files even when folder has no children (so last items get deleted) (#964)

* update obsolete call to pagedChildren on content handler. (#965)

* Bump fast-uri in /uSync.Backoffice.Management.Client/usync-assets (#954)

Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](fastify/fast-uri@v3.1.0...v3.1.2)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump postcss in /uSync.Backoffice.Management.Client/usync-assets (#956)

Bumps [postcss](https://github.com/postcss/postcss) from 8.5.8 to 8.5.14.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](postcss/postcss@8.5.8...8.5.14)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump postcss from 8.5.8 to 8.5.14 in /uSync.History/history-client (#957)

Bumps [postcss](https://github.com/postcss/postcss) from 8.5.8 to 8.5.14.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](postcss/postcss@8.5.8...8.5.14)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump uuid and @umbraco-cms/backoffice in /uSync.History/history-client (#960)

Bumps [uuid](https://github.com/uuidjs/uuid) to 14.0.0 and updates ancestor dependency [@umbraco-cms/backoffice](https://github.com/umbraco/Umbraco-CMS). These dependencies need to be updated together.


Updates `uuid` from 13.0.0 to 14.0.0
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](uuidjs/uuid@v13.0.0...v14.0.0)

Updates `@umbraco-cms/backoffice` from 17.3.0 to 17.5.0-rc
- [Release notes](https://github.com/umbraco/Umbraco-CMS/releases)
- [Commits](umbraco/Umbraco-CMS@release-17.3.0...release-17.5.0-rc)

---
updated-dependencies:
- dependency-name: "@umbraco-cms/backoffice"
  dependency-version: 18.0.0-rc1
  dependency-type: direct:development
- dependency-name: uuid
  dependency-version: 14.0.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump vite from 8.0.5 to 8.0.16 in /uSync.History/history-client (#969)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.5 to 8.0.16.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.0.16/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.0.16
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump vite in /uSync.Backoffice.Management.Client/usync-assets (#970)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.5 to 8.0.16.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.0.16/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.0.16
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump markdown-it in /uSync.Backoffice.Management.Client/usync-assets (#971)

Bumps [markdown-it](https://github.com/markdown-it/markdown-it) from 14.1.1 to 14.2.0.
- [Changelog](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
- [Commits](markdown-it/markdown-it@14.1.1...14.2.0)

---
updated-dependencies:
- dependency-name: markdown-it
  dependency-version: 14.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump js-yaml and @hey-api/openapi-ts in /uSync.History/history-client (#974)

Removes [js-yaml](https://github.com/nodeca/js-yaml). It's no longer used after updating ancestor dependency [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts). These dependencies need to be updated together.


Removes `js-yaml`

Updates `@hey-api/openapi-ts` from 0.95.0 to 0.97.0
- [Release notes](https://github.com/hey-api/openapi-ts/releases)
- [Changelog](https://github.com/hey-api/hey-api/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hey-api/openapi-ts/compare/@hey-api/openapi-ts@0.95.0...@hey-api/openapi-ts@0.97.0)

---
updated-dependencies:
- dependency-name: "@hey-api/openapi-ts"
  dependency-version: 0.97.0
  dependency-type: direct:development
- dependency-name: js-yaml
  dependency-version:
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Swap renamed alias order to match (old, new) (#961)

merge

* Fix build-package.ps1 restore skipping uSync.Extend, causing pack failures

uSync.Extend is excluded from the Debug solution configuration in uSync.slnx
(<Build Solution="Debug|*" Project="false" />). The restore step added
previously (dotnet restore $sln_name --force-evaluate) had no configuration,
so it defaulted to Debug and silently skipped restoring uSync.Extend - its
lock file stayed stale while every other project's got fixed. The later
build/pack steps run with --no-restore in $env (release), so they picked up
the stale lock file, which manifested as a NU1903 audit failure specifically
on uSync.Extend when packing.

Pass -p:Configuration=$env to the restore so it matches the build/pack
configuration and actually restores every project, including uSync.Extend.
Also commit the corrected uSync.Extend/packages.lock.json produced by that
restore, so the repo isn't left stale for the next person to hit this.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Fix blueprint path/parent resolution and auto-create missing containers (#985)

Content template (blueprint) exports stored the parent DocumentBlueprintContainer
as a raw, environment-specific int id in the friendly Path, and lost the parent
key entirely, because the lookups assumed the parent was always the same object
type as the item (DocumentBlueprint) rather than allowing for a container/folder.

- ContentSerializerBase: fall back to an untyped entity lookup for both the
  friendly path and the exported Parent key/name when the typed lookup fails,
  and add virtual hooks (FindItemAsTreeEntityAsync, CreateParentIfMissingAsync)
  so parents can be resolved/created as ITreeEntity rather than TObject.
- SyncTreeSerializerBase: CalculateNodePath/CalculateNodeLevel accept
  ITreeEntity? parents instead of TObject?, since TObject already implements it.
- ContentTemplateSerializer: resolve the parent as either an existing blueprint
  or its DocumentBlueprintContainer folder, and create the missing folder chain
  on import (same find-or-create-on-the-way pattern used for content/data types)
  instead of dropping the blueprint at the root or failing.

Fixes Jumoo/uSync.Complete.Issues#300.

* Add localization fallback defaults and translate UI into 5 languages (#972)

* Add localization fallback defaults and translate UI into 5 languages

Replace all uSync-owned localization calls (`localize.term`) with
`localize.termOrDefault`, supplying the English string as a fallback so
the UI renders correctly even before the localization system has loaded.
Umbraco core keys (e.g. `general_close`) are left as plain `term` calls
since those are guaranteed to exist in every Umbraco installation.

Add translations for Danish (da-dk), French (fr-fr), Spanish (es-es),
German (de-de), and Dutch (nl-nl), covering all uSync and USyncSettings
keys. Register all five new locales in the lang manifest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add more localization changes.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Avoid allocating 2 UTF-16 strings to compare json, use byte spans (#976)

* Use stack allocated spans instead of heap allocated arrays (#981)

* Use stack allocated spans instead of heap allocated arrays

* avoid the last tiny heap allocation in the copyTo, TryWriteBytes will do this allocation free.

---------

Co-authored-by: Kevin Jump <kevin@thejumps.co.uk>

* Pre-empt TryConvertTo InvalidCastExceptions (issue #304) (#986)

Two sources of swallowed first-chance InvalidCastExceptions during
push, ~100 each per run, that slow the app when a debugger is attached.

1. SyncEntityCache.GetName read from the entity cache (`cache`) while
   AddName wrote to `nameCache`. The entity cache holds IEntitySlim
   objects under the same id key, so every name lookup threw
   IEntitySlim -> CachedName and returned null - the name cache never
   actually worked. GetName now reads from nameCache.

2. Config/setting values arrive as JsonElement; Umbraco's TryConvertTo
   throws (and swallows) InvalidCastException turning a JsonElement into
   a value type e.g. bool. Added JsonTextExtensions.TryConvertPreChecked
   which does the JsonElement conversion with System.Text.Json first and
   only falls back to TryConvertTo. Routed the value/config wrappers
   (ConversionExtensions, SyncValueMapperBase, SyncSerializerOptions,
   HandlerSettingsExtensions) through it.

Adds tests for both fixes.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Consolidate object conversions onto TryGetValueAs (JsonElement pre-check) (#987)

* Merge JsonElement pre-check into existing TryGetValueAs

TryGetValueAs already did object -> T conversion with the same shape as
the new TryConvertPreChecked, so fold the JsonElement pre-check into it
(nicer name, one method) and use it everywhere.

TryGetValueAs is now public and skips the pre-check for string targets:
Umbraco's TryConvertTo already turns a JsonElement into a string without
throwing, and routing an object/array JsonElement through
Deserialize<string> would throw - reintroducing the exact first-chance
exception this change avoids. Its two existing string callers keep their
current behaviour.

Renames the test file to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Route remaining TryConvertTo calls through TryGetValueAs

Consolidates the object -> T conversions onto the single TryGetValueAs
method so they all get the JsonElement pre-check, and adds a non-generic
Type overload for the two callers that only have a runtime Type
(ContentTypeSerializer history-cleanup, ContentSerializerBase value diff).

Converted: XElementExtensions (value/attribute ValueOrDefault,
CreateOrSetElement), ObjectPropertyExtensions, ListExtensions,
JsonTextExtensions.GetPropertyValueOrDefault, MediaPicker3Mapper,
MemberGroupPickerManager, DomainSerializer, ContentTypeSerializer,
ContentTypeBaseSerializer.

Left ContentTypeBaseSerializer.SerializeNewProperty on TryConvertTo: it
writes an empty XElement when conversion succeeds with a null result, a
success-vs-null distinction TryGetValueAs deliberately collapses (null ->
false). Converting it would drop empty elements and cause spurious diffs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Route SerializeNewProperty through TryGetValueAs too

Converts the last object -> T conversion so TryConvertTo is only used in
one place (inside TryGetValueAs itself). TryGetValueAs treats a null
conversion result as failure, so the else branch keeps writing an empty
XElement - the property is still recorded in the xml, matching the old
success-with-null behaviour. The old hard-fail-writes-nothing case is
unreachable in practice here (reflected value-type properties return
boxed defaults, not null; string already took the empty path).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Optimise XElementExtensions value conversion and hashing (#988)

Two hot-path optimisations in XElementExtensions:

1. ValueOrDefault<TObject> (XElement + XAttribute overloads) now fast-paths
   the value types actually used (int, Guid, bool, enum) with direct parsers
   before falling back to Umbraco's reflection-based TryConvertTo. These
   getters run for (almost) every attribute of every node during a
   report/import, so avoiding the reflection/exception overhead adds up.
   The typeof(TObject) checks are JIT-folded per generic instantiation.

2. MakePlatformSafeHashAsync streams the XML straight through a CryptoStream
   instead of buffering the entire serialised document into a MemoryStream
   before hashing. The hashed byte sequence is unchanged, so hashes stay
   stable across platforms.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Stream item keys for clean operations instead of full XML parse (#989)

The 'clean' import path needs only the Key attribute for every item in a
folder, but was fully parsing each .config file (XElement.LoadAsync with
PreserveWhitespace) to read it. On large content/media trees this is a
second full file-IO + parse pass over the folder during every import that
contains clean markers.

Add ISyncFileService.LoadKeyFromFileAsync which streams the file with an
XmlReader, reads the Key attribute off the root element and stops - no DOM
allocation, no reading the rest of the document.

Wire it into the clean path:
 - SyncHandlerRoot.GetFolderKeysAsync (the per-folder key scan)
 - SyncHandlerRoot.GetCleanParentAsync
 - SyncHandlerBase.GetCleanParentKeyAsync, which also now reuses the key
   for the parent lookup instead of loading the clean file twice.

Behaviour is unchanged: the root Key attribute is present on both normal
and 'empty' (delete/rename/clean) nodes, files without a Key still yield
Guid.Empty, and read errors still throw so a corrupt file aborts the clean
rather than silently allowing deletes.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Perf: scope handler runtime-cache per operation, skip cleanup on flat+guid (#990)

Two ExportOnSave / bulk-operation performance fixes from the perf review.

#5 - runtime-cache scope (was keyed by managed thread id):
GetCacheKeyBase() built its key from Environment.CurrentManagedThreadId.
Across an await a continuation can resume on a different thread, so the
key changed mid-operation - the child-item / folder-key caches missed
(extra entityService calls) and the end-of-operation cleanup (on another
thread) never cleared the entries it created, leaking them into the shared
runtime cache.

Replace the thread id with an AsyncLocal<string> scope id that flows with
the async operation. PrepCaches/CleanCaches (import + report) and the
top-level ExportAllAsync now begin/end a scope via BeginCacheScope/
EndCacheScope, and ImportAllAsync/ReportAsync run the cleanup in a finally
so entries are always released. Callers with no active scope (paged import,
ad-hoc tree/dependency lookups) fall back to the thread id, so their
behaviour is unchanged.

#3 - skip CleanUp folder scan on flat + guid names:
On every save/move/delete, SyncHandlerRoot.CleanUpAsync recursively reads
the whole handler folder tree looking for duplicate files to mark as
renames. With a flat structure and guid file names an item's file is always
"{key}.{ext}" in the same folder - it never changes name or location - so
there is nothing to clean. Add an early return for that case to the base
handler (Content/Media already made this check in their override, this
extends it to the settings/level/container handlers).

Build clean; uSync.Tests 137/137 pass.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* Investigation: batched content/media save on import (perf #1) (#991)

Findings doc (no code changes). Decompiled Umbraco 17.3 ContentService to
compare Save(item) vs Save(IEnumerable), and traced uSync's import scope
handling.

Conclusion: bulk Save is not a safe general win for content/media -
 - the batch overload still writes one row per item (no set-based SQL), so
   the dominant cost is unchanged;
 - its only saving (N->1 transactions + N->1 notifications) either is already
   provided by uSync's ambient suppressed scope (DisableNotificationSuppression
   = false), or, in the default config, directly conflicts with the per-item
   failure isolation that default is intentionally designed to give;
 - it also drops per-item error attribution and two validations.

Recommends leaving the (already-present but dormant) bulk hook off for
content/media and using the existing config levers instead.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jason Elkin <jasonelkin86@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Henrik <Henrik.Gedionsen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants