Skip to content

Further fix to configuration classes using ISet, resolving regression with custom 404 pages #19573

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Jun 16, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Resolves: #19567

Description

The cause of this issue was another cases of issues involved in the fix #19229, where ISet in configuration classes aren't bound.

Note that I've added a compatibility suppression for the breaking change, which I don't see how we can otherwise avoid.

Testing

Prepare a custom 404 page as per the instructions in the documentation (though note that I found this didn't work when using the name "404" for the document type and template, and instead used "File Not Found"). With this PR in place, the custom 404 should be displayed as expected.

To check via debugging, put a breaking point at the start of NotFoundHandlerHelper.GetCurrentNotFoundPageId and verify the error404Collection parameter matches the configured value.

Release

Can consider for a 16.0.1, otherwise 16.1.0.

@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 20:06
Copy link
Contributor

@Copilot Copilot AI left a comment

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 the binding regression for custom 404 pages by changing the configuration property type and updating affected tests, and suppresses a compatibility warning.

  • Changed Error404Collection from ISet<ContentErrorPage> to IEnumerable<ContentErrorPage> with a C# 12 collection expression default.
  • Updated unit test initializer syntax in ContentSettingsValidatorTests.cs to use [...].
  • Added a compatibility suppression for the breaking change in CompatibilitySuppressions.xml.

Reviewed Changes

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

File Description
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidatorTests.cs Switched collection initializer syntax to C# 12 [...]
src/Umbraco.Core/Configuration/Models/ContentSettings.cs Changed property type from ISet to IEnumerable
src/Umbraco.Core/CompatibilitySuppressions.xml Added suppression for CP0002 on Error404Collection
Comments suppressed due to low confidence (2)

src/Umbraco.Core/Configuration/Models/ContentSettings.cs:53

  • Changing Error404Collection from ISet to IEnumerable removes set semantics and mutability; consider using IReadOnlySet or IReadOnlyCollection to preserve uniqueness and clearly express intended behavior.
public IEnumerable<ContentErrorPage> Error404Collection { get; set; } = [];

src/Umbraco.Core/Configuration/Models/ContentSettings.cs:50

  • [nitpick] The XML doc still implies set behavior; update the summary to reflect the change to an IEnumerable and clarify whether duplicates are permitted.
///     Gets or sets a value for the collection of error pages.

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.

Custom 404 Error Page not working in umbraco 16
1 participant