Skip to content

Use OfType instead of Cast when iterating nested content config array#904

Merged
KevinJump merged 2 commits intov17/nested-contentfrom
copilot/sub-pr-903
Mar 4, 2026
Merged

Use OfType instead of Cast when iterating nested content config array#904
KevinJump merged 2 commits intov17/nested-contentfrom
copilot/sub-pr-903

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

contentTypesArray.Cast<JsonObject>() throws InvalidCastException if the legacy contentTypes array contains any non-object entries (nulls, primitives). Replaced with OfType<JsonObject>() to silently skip incompatible elements.

Change

  • NestedContentMigratingConfig.cs: Cast<JsonObject>()OfType<JsonObject>() in the contentTypes iteration loop
// Before — throws on non-object entries
foreach (var contentType in contentTypesArray.Cast<JsonObject>())

// After — skips non-object entries gracefully
foreach (var contentType in contentTypesArray.OfType<JsonObject>())

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on V17 nested content PR Use OfType instead of Cast when iterating nested content config array Mar 4, 2026
@KevinJump KevinJump marked this pull request as ready for review March 4, 2026 14:40
@KevinJump KevinJump merged commit 95d7a47 into v17/nested-content Mar 4, 2026
@KevinJump KevinJump deleted the copilot/sub-pr-903 branch March 4, 2026 14:41
KevinJump added a commit that referenced this pull request Mar 4, 2026
* Add support for direct migration of nested content to blocklist. (as part of a sync).

* media item - logging parent fail

* Update uSync.Core/Serialization/Serializers/MediaSerializer.cs

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

* Update uSync.Core/Mapping/Mappers/NestedContentToBlockListHelper.cs

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

* Use OfType instead of Cast when iterating nested content config array (#904)

* Initial plan

* Use OfType instead of Cast for resilience to non-object array entries

Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>

* Add NUnit migration tests for NestedContentMigratingConfig (#905)

* Initial plan

* Fix MediaSerializer build error and plan nested content migration tests

Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>

* Add NUnit migration tests for NestedContentMigratingConfig

Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: KevinJump <431231+KevinJump@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants