Skip to content

Fix not-found pages issue (#12370)#12424

Open
msynk wants to merge 1 commit into
bitfoundation:developfrom
msynk:12370-infra-notfound-page-issues
Open

Fix not-found pages issue (#12370)#12424
msynk wants to merge 1 commit into
bitfoundation:developfrom
msynk:12370-infra-notfound-page-issues

Conversation

@msynk
Copy link
Copy Markdown
Member

@msynk msynk commented Jun 6, 2026

closes #12370

Summary by CodeRabbit

  • Bug Fixes
    • Improved HTTP error page handling to prevent response flushing errors across multiple server applications.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Too many files changed? Review this PR in Change Stack to see how the pieces fit before you dive in.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 01bf5b73-384e-44df-9ab2-5ed0df9a476f

📥 Commits

Reviewing files that changed from the base of the PR and between ac60e3d and 300f8a3.

📒 Files selected for processing (4)
  • src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs
  • src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs
  • src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs
  • src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs

Walkthrough

Four middleware files across BlazorUI Demo and website projects update HTTP error-page handling to defer status code assignment to Response.OnStarting callbacks. The pattern prevents exceptions during Blazor response rendering by avoiding immediate status code changes that could trigger body flushing.

Changes

HTTP Status Code Deferred Assignment

Layer / File(s) Summary
BlazorUI Demo 401/403/404 Error Pages
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs
Routes containing "not-found" and "not-authorized" now defer status code setting via Response.OnStarting callbacks. For "not-authorized", the choice between 401 Unauthorized and 403 Forbidden is determined by the isForbidden query parameter. Comments clarify the interaction with Blazor rendering and UseStatusCodePages middleware.
Website 404 Error Pages
src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs, src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs, src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs
Routes containing "not-found" now set 404 NotFound status code inside Response.OnStarting callbacks instead of direct assignment, consistent with the BlazorUI Demo pattern.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop, skip, and a deferred callback,
Status codes now wait their turn in the stack,
Before headers fly, the code finds its place,
No Blazor confusion—just grace upon grace!
The 404s and 401s align,
Delayed but not denied—a pattern divine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change - fixing the not-found pages issue with a reference to the related issue #12370, directly matching the PR's objective.
Linked Issues check ✅ Passed The PR modifies middleware to defer HTTP status code assignment via OnStarting callbacks to prevent errors during response body handling, directly addressing the UnknownException issue reported in #12370.
Out of Scope Changes check ✅ Passed All four modified middleware files address the same core issue of fixing not-found and unauthorized page handling, with no unrelated changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

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 addresses issue #12370 where navigating to /not-found on bitplatform.dev caused an exception instead of rendering the expected 404 UI, by deferring 404/401/403 status code assignment until the response is starting (so Blazor can render and flush the page body normally).

Changes:

  • Defer setting the /not-found HTTP 404 status code via HttpResponse.OnStarting in the Sales, Platform, and Careers websites.
  • Defer setting /not-found (404) and /not-authorized (401/403) status codes via OnStarting in the BlazorUI Demo server, with an added inline explanation of the underlying Blazor/StatusCodePages interaction.

Reviewed changes

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

File Description
src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs Defers /not-found status code to response start to avoid interfering with Blazor rendering / status-code handling.
src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs Same deferred 404 approach for the Platform site (the site affected by #12370).
src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs Aligns Careers site behavior by deferring the 404 status code for /not-found.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs Defers 404/401/403 status codes for not-found/not-authorized pages and documents the rationale tied to enhanced navigation headers.

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.

Opening the not-found URL on bitplatform.dev results in UnknownException

2 participants