[release/11.0-preview7] FileConfigurationProvider: Handle and forward IO exceptions to OnLoadException - #131427
Merged
mrek-msft merged 1 commit intoJul 27, 2026
Conversation
…Exception (dotnet#126093) Current behavior of FileConfigurationProvider on various types of failures at various times: | | First Load | OnChange Reload | |---|---|---| | data parsing failure | `OnLoadException` callback is called<br>`AddJsonFile` throws<br><br> | `OnLoadException` callback is called<br>program continues<br>no reload happen | | IO failure on file open | `AddJsonFile` throws | Silent<br>program continues<br>no reload happen<br>possibly raises `UnobservedTaskException` later | This PR unifies it in a way that both types of failure behave same as _data parsing failure_. This brings some behavioral changes - `OnLoadException` callback is newly triggered if IO error happen on both types of events (first load, reload) - `UnobservedTaskException` can no longer be observed in scenario when user registers `OnLoadException` callback. It can however happen when no callback is registered, so XML comment on `OnLoadException` was updated. - `OnLoadException` callbacks now receives not only InvalidDataException, but also IOException (or any other exception which (possibly custom) implementation of IFileProvider can throw). If user cast to InvalidDataException, he may miss other exceptions or get cast exceptions. Based on follow up Copilot code reviews, I did few more behavior changes at edge cases, they do not relate directly to issue and can be reverted independently if not desired. - `OnReload()` now fires only when Data actually changed. Previously on first load, if a parse or IO error occurred and `OnLoadException` set `Ignore = true`, `OnReload()` was fired unconditionally even though Data was never modified. The new code fires `OnReload()` only when Data was successfully loaded or explicitly cleared (e.g., on reload or optional missing file). For consecutive reloads with parse errors, Data is cleared and `OnReload()` still fires. This change is independent on original fix and can be reverted independently if not desirable. Fix dotnet#113964 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mrek-msft
requested review from
Copilot and
svick
and removed request for
Copilot
July 27, 2026 17:16
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
cincuranet
approved these changes
Jul 27, 2026
Member
Author
|
/ba-g Only unrelated known iOS errors |
Member
Author
|
Adding servicing-approved. Based on discussion in tactics email, since it is not code complete yet, no servicing approval is needed. |
mrek-msft
merged commit Jul 27, 2026
253bde0
into
dotnet:release/11.0-preview7
91 of 96 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #126093 to release/11.0-preview7
Customer Impact
Long standing issue reported by customer
Regression
Long standing issue.
Testing
6 tests were added.
Risk
Low. It is backport to Preview 7 version after branch were snapped but before code complete.