Skip to content

doc(Server): unify 404/500 handling through the Error page - #8911

Merged
ArgoZhang merged 13 commits into
mainfrom
fix-dtm
Dec 4, 2026
Merged

ArgoZhang merged 13 commits into
mainfrom
fix-dtm

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #8910

Summary By Copilot

  • Point Router.NotFoundPage to the Error page, delete the NotFound page, and handle unknown Blazor routes in Error.razor.
  • Add the /error/{StatusCode:int?} route; a 404 or a missing status code redirects to the home page.
  • Rename PrintLayout to EmptyLayout and use it for both the Error page and PrintView.
  • Re-execute status-code pages through /error/{0}, route the MVC exception handler to /error, and redirect the unknown MVC fallback to the home page.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Changes are limited to the sample site (BootstrapBlazor.Server); the component library API is unchanged.

Verification

  • Manual (required)
  • Automated

No build or tests were run for this PR-only task; only the branch diff was checked, and no browser verification was performed.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

UI

Use the shared error page for unmatched routes and redirect null or 404 status codes to the home page.

  • src/BootstrapBlazor.Server/Components/Pages/Error.razor L2-5, L20-37
  • src/BootstrapBlazor.Server/Components/Routes.razor L1

Replace the print-specific layout with the empty layout for the print view.

  • src/BootstrapBlazor.Server/Components/Samples/PrintView.razor L2
  • src/BootstrapBlazor.Server/Components/Layout/EmptyLayout.razor

Configuration

Configure exception and status-code handling to use the error route, and redirect unmatched requests to the home page.

  • src/BootstrapBlazor.Server/Program.cs L35-36, L45-47, L69-75

Other changes

Files not grouped.

  • src/BootstrapBlazor.Server/Components/Pages/NotFound.razor (deleted)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the bug Something isn't working label Dec 4, 2026
@bb-auto bb-auto Bot added this to the v11.1.0 milestone Dec 4, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 11b7de4

#8910 fix(Server): prevent first-paint theme flash and fix pt-BR time format · 4 of 5 met

# Requirement Status Notes
1 Initialize the initial HTML with the saved theme, or the system theme when set to auto. ✅ Met The inline script in App.razor reads localStorage before the stylesheets load and applies the selected or system theme.
2 Use the TimeSpan-compatible hh:mm:ss format for the pt-BR DateTimePicker. ✅ Met The pt-BR DateTimePicker TimeFormat is hh:mm:ss.
3 Use the TimeSpan-compatible hh:mm:ss format for the pt-BR DateTimeRange. ❌ Not addressed The pt-BR DateTimeRange TimeFormat is still HH:mm:ss.
4 Remove the empty ErrorLayout and its usage on the Error page. ✅ Met No ErrorLayout definition or usage remains in the server project.
5 Add request exception logging that includes the Range header and whether the response has started. ✅ Met The middleware logs the method, path, trace ID, Range header, and ResponseStarted value.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 3 issues

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: src/BootstrapBlazor.Server/Components/Pages/Error.razor:2, src/BootstrapBlazor.Server/Components/App.razor:10


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

<head>
<script>
(() => {
const theme = localStorage.getItem('theme') ?? 'auto';

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.

🟡 Medium · System theme is not applied

When browser policy blocks access to local storage, localStorage.getItem throws before matchMedia runs, aborting the script and leaving the page with its hard-coded light theme instead of the system theme.

Catch local-storage access errors and fall back to auto so the script can read the system preference.

const activeTheme = theme === 'auto'
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
: theme;
document.documentElement.setAttribute('data-bs-theme', activeTheme);

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.

⚪ Low · Theme setup bypasses JSInterop

When the first-paint theme initializer runs, the inline script calls document.documentElement.setAttribute directly instead of using JSInterop, violating the repository’s DOM-access rule.

Replace the direct DOM mutation with a repository-approved JSInterop-based DOM update.

From docs/agents/component-checklist.md L21:

- 不直接操作 DOM(用 JSInterop)

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e2909ea) to head (6b8cc5f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8911   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          664       664           
  Lines        30526     30526           
=========================================
  Hits         30526     30526           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@ArgoZhang ArgoZhang changed the title fix(Server): prevent first-paint theme flash and fix pt-BR time format fix(Localizer): prevent first-paint theme flash and fix pt-BR time format Dec 4, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

# Conflicts:
#	src/BootstrapBlazor.Server/Components/Pages/Error.razor

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@ArgoZhang ArgoZhang changed the title fix(Localizer): prevent first-paint theme flash and fix pt-BR time format fix(Server): unify 404/500 handling through the Error page Dec 4, 2026
@ArgoZhang ArgoZhang changed the title fix(Server): unify 404/500 handling through the Error page doc(Server): unify 404/500 handling through the Error page Dec 4, 2026
@ArgoZhang ArgoZhang removed the bug Something isn't working label Dec 4, 2026
@ArgoZhang ArgoZhang added the documentation Improvements or additions to documentation label Dec 4, 2026
@ArgoZhang
ArgoZhang merged commit 4aee1eb into main Dec 4, 2026
7 checks passed
@ArgoZhang
ArgoZhang deleted the fix-dtm branch December 4, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(Server): unify 404/500 handling through the Error page

1 participant