Skip to content

chore: Fix exception thrown on TOC loading internally - #9974

Merged
vicancy merged 3 commits into
dotnet:mainfrom
filzrev:chore-fix-internal-exception-on-toc-loading
Sep 24, 2026
Merged

vicancy merged 3 commits into
dotnet:mainfrom
filzrev:chore-fix-internal-exception-on-toc-loading

Conversation

@filzrev

@filzrev filzrev commented May 31, 2024

Copy link
Copy Markdown
Collaborator

This PR is intended to fix internal exception that occurred when deserializing toc.yml file.

Current docfx implementation use YamlDeserializerWithFallback class to deserialize toc.yml file.
And following operation executed.

  1. Try to deserialize yml as List<TocItemViewModel>.
  2. If YamlException is thrown. then deserialize as TocItemViewModel.

This PR intended to fix following problems.

  • On current implementation try-catch logics are used when deserializing TocItemViewModel as List<TocItemViewModel> .
    -> Exceptions should not be thrown in the normal execution flow.
  • When deserializing as TocItemViewModel. It requires to open safe file twice.

@filzrev filzrev changed the title chore: Fix internal exception on TOC loading chore: Fix exception thrown on TOC loading internally May 31, 2024
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from 16d74d0 to 76497b3 Compare May 31, 2024 13:57
@codecov

codecov Bot commented May 31, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.81%. Comparing base (fe673ec) to head (9d56541).
Report is 211 commits behind head on main.

Files Patch % Lines
src/Docfx.Build/TableOfContents/TocHelper.cs 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9974      +/-   ##
==========================================
+ Coverage   74.31%   78.81%   +4.49%     
==========================================
  Files         536      539       +3     
  Lines       23189    23440     +251     
  Branches     4056     4063       +7     
==========================================
+ Hits        17234    18474    +1240     
+ Misses       4853     3822    -1031     
- Partials     1102     1144      +42     

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

}
}

private static bool IsListTocItems(StreamReader reader)

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.

This looks a bit complicated. For handling YAML, I'm leaning towards we move to a future where YAML are parsed into a JSON node tree, and then deserialized to objects with standard JsonConverter.

Similar to https://github.com/dotnet/docfx/blob/v3/src/docfx/lib/json/YamlUtility.cs#L112 but with System.Text.Json.

@filzrev filzrev Jun 20, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This looks a bit complicated.

I've removed stream unwind logics.
Instead, change logics to read entire YAML content first.
Then check TOC type by using YAML Parser.

@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from 76497b3 to c5cffd3 Compare June 20, 2024 09:22
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from c5cffd3 to 9d56541 Compare June 20, 2024 09:50
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from 280054a to 323b0ce Compare October 21, 2024 10:01
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch 3 times, most recently from c96cab0 to 1078ab7 Compare February 20, 2025 03:41
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch 2 times, most recently from 4854ce2 to 109e52c Compare March 11, 2025 04:14
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from 109e52c to e8f04cd Compare April 6, 2025 17:37
@filzrev
filzrev force-pushed the chore-fix-internal-exception-on-toc-loading branch from e8f04cd to 6e3642b Compare April 14, 2025 16:54
phunkeler pushed a commit to phunkeler/Plugin.Maui.NearbyConnectivity that referenced this pull request Oct 12, 2026
Updated [docfx](https://github.com/dotnet/docfx) from 2.78.5 to 2.81.0.

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

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

## 2.81.0

## What's Changed

### ✨ Features & Platform Support

* Allow custom templates to override `search.min.js` in the modern
template by @​filzrev in
[#​10055](dotnet/docfx#10055).
* Add `metadata.sourceLinkExclude` to exclude selected source paths from
**View Source** links without removing API documentation by @​vicancy in
[#​11141](dotnet/docfx#11141).
* Record the DocFX build version in the `docfx_version` field of
`manifest.json` by @​vicancy in
[#​11162](dotnet/docfx#11162).
* Add a .NET 11 RC target, including support for the .NET 11 Razor
source generator, while retaining .NET 8, 9, and 10 targets by @​vicancy
and @​filzrev in [#​11176](dotnet/docfx#11176)
and [#​11182](dotnet/docfx#11182).

### ⚡ Performance & Reliability

* Reduce JavaScript template processing overhead and memory allocations
by reusing parsed scripts and improving model conversion. Add execution
limits to prevent runaway scripts from hanging builds by @​lahma in
[#​11084](dotnet/docfx#11084).
* Avoid unnecessary exceptions and repeated file reads when loading
`toc.yml` by @​filzrev in
[#​9974](dotnet/docfx#9974).

### 🐛 Bug Fixes

* Restore source links for partial types extended by source generators
by @​vicancy in [#​11141](dotnet/docfx#11141).
* Fix local namespace links in managed reference documentation by
resolving them through xrefs during site generation by @​vicancy in
[#​11163](dotnet/docfx#11163).
* Preserve nested XML blocks when inserting Markdown separators,
preventing content from incorrectly rendering as code blocks by
@​vicancy in [#​11175](dotnet/docfx#11175).
* Preserve explicit `false` and `0` values when overwriting nullable
properties by @​vicancy in
[#​11181](dotnet/docfx#11181).

### 📦 Dependency Updates

* Update Jint to **4.16.3** in
[#​11157](dotnet/docfx#11157).
* Update Markdig to **1.4.0** in
[#​11158](dotnet/docfx#11158) and
[#​11160](dotnet/docfx#11160).
* Update YamlDotNet to **18.1.0** in
[#​11167](dotnet/docfx#11167).
* Update PdfPig to **0.1.16** in
[#​11168](dotnet/docfx#11168).
* Update ICSharpCode.Decompiler to **11.1.0.9782** in
[#​11184](dotnet/docfx#11184).
* Update System.Composition to **10.0.12** in
[#​11165](dotnet/docfx#11165).

### Upgrade Notes

Custom JavaScript template preprocessors now enforce a **30-second
timeout** and a **50-million-statement limit** for each `getOptions` or
`transform` invocation. Long-running custom scripts may need adjustment.

**Full Changelog**:
dotnet/docfx@v2.80.1...v2.81.0

## 2.80.1

<!-- Release notes generated using configuration in .github/release.yml
at main -->

## What's Changed
### 💪 Other Changes
* fix: preserve thematic breaks in overwrite Markdown by @​vicancy in
dotnet/docfx#11142
* fix: XML comment parse logics for block element that is adjacent to
markdown content by @​filzrev in
dotnet/docfx#10966
* chore: Update Roslyn and Microsoft.Build package dependencies by
@​filzrev in dotnet/docfx#11124
* fix: preserve indentation around XML comment code blocks by @​vicancy
in dotnet/docfx#11143
* fix: stop metadata generation when restore fails by @​vicancy in
dotnet/docfx#11146
* fix: clarify empty .NET API diagnostics by @​vicancy in
dotnet/docfx#11145
* fix: share tool templates across target frameworks by @​vicancy in
dotnet/docfx#11144
* fix: honor TOC metadata while preserving file metadata overrides by
@​vicancy in dotnet/docfx#11140
* fix(deps): update esbuild to 0.28.1 and tsx to 4.22.4 by
@​dependabot[bot] in dotnet/docfx#11077
* feat(pdf): allow footer and header on cover and toc by @​sergimos in
dotnet/docfx#10958
* chore(deps): bump actions/setup-dotnet from 5 to 6 by
@​dependabot[bot] in dotnet/docfx#11116
* chore(deps): bump actions/checkout from 6 to 7 by @​dependabot[bot] in
dotnet/docfx#11115
* Bump Markdig from 1.1.0 to 1.1.1 by @​dependabot[bot] in
dotnet/docfx#11024
* deps: Update JsonSchema.Net dependency to 8.0.5 by @​filzrev in
dotnet/docfx#10964

## New Contributors
* @​sergimos made their first contribution in
dotnet/docfx#10958

**Full Changelog**:
dotnet/docfx@v2.78.6...v2.80.1

## 2.78.6

<!-- Release notes generated using configuration in .github/release.yml
at main -->

## What's Changed
### 💪 Other Changes
* chore(deps): bump dependabot/fetch-metadata from 2.3.0 to 2.5.0 by
@​dependabot[bot] in dotnet/docfx#10956
* chore(deps): bump paulhatch/semantic-version from 5.4.0 to 6.0.1 by
@​dependabot[bot] in dotnet/docfx#10978
* chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 in /templates by
@​dependabot[bot] in dotnet/docfx#11016
* Bump Jint from 4.6.0 to 4.6.1 by @​dependabot[bot] in
dotnet/docfx#11018
* chore(deps): bump actions/upload-artifact from 6 to 7 by
@​dependabot[bot] in dotnet/docfx#11015
* chore(deps): bump actions/download-artifact from 7 to 8 by
@​dependabot[bot] in dotnet/docfx#11014
* Bump Markdig from 1.0.0 to 1.1.0 by @​dependabot[bot] in
dotnet/docfx#11019
* chore: remove unnecessary using to fix the Lint check by @​lahma in
dotnet/docfx#11085
* Make xref archive download test hermetic by @​vicancy in
dotnet/docfx#11092
* fix: treat different ports as external links by @​vicancy in
dotnet/docfx#11091
* chore: cleanup YamlSerializationTest.cs by @​filzrev in
dotnet/docfx#10974
* chore(deps-dev): bump follow-redirects from 1.15.11 to 1.16.0 in
/templates by @​dependabot[bot] in
dotnet/docfx#11062
* chore(deps): bump postcss from 8.5.6 to 8.5.14 in /templates by
@​dependabot[bot] in dotnet/docfx#11070
* chore(deps): bump uuid and mermaid in /templates by @​dependabot[bot]
in dotnet/docfx#11073
* chore(deps-dev): bump lodash from 4.17.23 to 4.18.1 in /templates by
@​dependabot[bot] in dotnet/docfx#11061
* chore(deps): bump fast-uri from 3.1.0 to 3.1.2 in /templates by
@​dependabot[bot] in dotnet/docfx#11071
* chore(deps): bump mermaid from 11.15.0 to 11.16.1 in /templates by
@​dependabot[bot] in dotnet/docfx#11093
* chore(deps): bump dompurify from 3.3.1 to 3.4.13 in /templates by
@​dependabot[bot] in dotnet/docfx#11096
* chore(deps-dev): bump js-yaml from 4.1.1 to 4.3.1 in /templates by
@​dependabot[bot] in dotnet/docfx#11095
* chore(deps): bump postcss from 8.5.14 to 8.5.26 in /templates by
@​dependabot[bot] in dotnet/docfx#11094
* chore(deps): bump fast-uri from 3.1.2 to 3.1.5 in /templates by
@​dependabot[bot] in dotnet/docfx#11097
* chore(deps-dev): bump socket.io-parser from 4.2.5 to 4.2.7 in
/templates by @​dependabot[bot] in
dotnet/docfx#11098
* chore(deps): bump ws, engine.io-client, engine.io and
socket.io-adapter in /templates by @​dependabot[bot] in
dotnet/docfx#11101
* chore(deps-dev): bump brace-expansion from 1.1.12 to 1.1.18 in
/templates by @​dependabot[bot] in
dotnet/docfx#11099
* deps: Update playwright version to 1.60.0 by @​filzrev in
dotnet/docfx#11074
* deps: Update roslyn package versions to 5.6.0 by @​filzrev in
dotnet/docfx#11047
* fix(deps): apply compatible npm security updates by @​vicancy in
dotnet/docfx#11105
* Bump the spectre group with 2 updates by @​dependabot[bot] in
dotnet/docfx#11102
* Bump the xunit group with 1 update by @​dependabot[bot] in
dotnet/docfx#11107
* Fix typo in Schema Document Processor overview by @​smartcaveman in
dotnet/docfx#11005
* Bump coverlet.collector from 8.0.0 to 8.0.1 by @​dependabot[bot] in
dotnet/docfx#11045
* chore(deps): bump paulhatch/semantic-version from 6.0.1 to 6.0.2 by
@​dependabot[bot] in dotnet/docfx#11036
* chore(deps): bump dependabot/fetch-metadata from 2.5.0 to 3.0.0 by
@​dependabot[bot] in dotnet/docfx#11051
* chore(deps): bump actions/deploy-pages from 4 to 5 by
@​dependabot[bot] in dotnet/docfx#11049
* chore(deps): bump azure/login from 2 to 3 by @​dependabot[bot] in
dotnet/docfx#11035
* Bump Jint from 4.6.1 to 4.6.3 by @​dependabot[bot] in
dotnet/docfx#11032
* chore(deps): bump dorny/test-reporter from 2.5.0 to 3.0.0 by
@​dependabot[bot] in dotnet/docfx#11043
* Bump AwesomeAssertions from 9.4.0 to 9.5.0 by @​dependabot[bot] in
dotnet/docfx#11114
* chore(deps): bump dependabot/fetch-metadata from 3.0.0 to 3.1.0 by
@​dependabot[bot] in dotnet/docfx#11110
* chore(deps): bump paulhatch/semantic-version from 6.0.2 to 6.0.3 by
@​dependabot[bot] in dotnet/docfx#11112
* chore(deps): bump actions/upload-pages-artifact from 4 to 5 by
@​dependabot[bot] in dotnet/docfx#11109
* chore(deps): bump codecov/codecov-action from 5 to 7 by
@​dependabot[bot] in dotnet/docfx#11113
* chore(deps): bump actions/github-script from 8 to 9 by
@​dependabot[bot] in dotnet/docfx#11111
* Bump the xunit group with 1 update by @​dependabot[bot] in
dotnet/docfx#11117
* Bump coverlet.collector from 8.0.1 to 10.0.1 by @​dependabot[bot] in
dotnet/docfx#11119
* Bump Microsoft.NET.Test.Sdk from 18.0.1 to 18.9.0 by @​dependabot[bot]
in dotnet/docfx#11122
 ... (truncated)

Commits viewable in [compare
view](dotnet/docfx@v2.78.5...v2.81.0).
</details>

Updated [dotnet-coverage](https://github.com/microsoft/codecoverage)
from 18.9.0 to 18.12.0.

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

_Sourced from [dotnet-coverage's
releases](https://github.com/microsoft/codecoverage/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/microsoft/codecoverage/commits).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Oct 12, 2026
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.

3 participants