Commit fb4d951
authored
Fix Foundatio NRT nullable reference type errors (#2202)
* Update dependencies
- Update Foundatio libraries to the latest beta versions across the Core, Insulation, and Test projects.
* Fix Foundatio NRT errors in Configuration, Job, and WorkItemHandler files (batch 1/3)
Foundatio packages upgraded to versions with nullable reference types enabled, causing 135 build errors. This batch fixes 102 errors across 30 files by:
- Updating Dictionary<string, string> to Dictionary<string, string?> for connection string data
- Changing ILock return types to ILock? for lock acquisition methods
- Adding null guards for QueueEntry.Value and WorkItemContext.GetData<T>() which are now nullable
- Adding diagnostic logging for null defensive guards to improve observability
Remaining 33 errors in Repositories, Services, Billing, and Migrations will be addressed in subsequent batches.
* Fix Foundatio NRT errors in Core domain layer (batch 2/3)
Foundatio 11.x introduces nullable reference types across infrastructure APIs
(ILockProvider, ICacheClient, FindResults, QueueEntry, etc.). Batch 2 adapts
Repositories, Services, Extensions, Models, Plugins, Mail, Migrations, Billing,
and Utility files to handle nullable returns and stricter nullability contracts.
Key changes:
- Add null guards after GetByIdAsync (returns T? now)
- Use .OfType<T>() to filter null collection elements
- Guard nullable keys before ICacheClient.GetAsync
- Handle DateRange init-only properties via Remove/re-add pattern
- Add logging when operations silently skip missing entities
- Change return types where Foundatio APIs now return nullable
Brings Exceptionless.Core to 0 build errors. Tests blocked by 8 pre-existing
Insulation errors (batch 3).
* Fix pre-canceled CancellationToken in lock acquisition
Copilot review identified 11 instances where \
ew CancellationToken(true)\
(already canceled) was passed to lock acquisition methods. This caused locks
to be immediately canceled, preventing jobs/handlers from running.
Changed all lock acquisition calls to pass through the method's
\cancellationToken\ parameter instead, allowing proper lock acquisition and
job execution.
* Fix Foundatio NRT errors in Insulation, Web, and test projects
Foundatio now exposes NRT annotations. This commit adapts all
consuming code:
- Insulation: update GetAWSCredentials/GetAWSRegionEndpoint parameter
types from IDictionary<string,string> to IDictionary<string,string?>,
add null check on GeoIP database stream
- Web controllers: use null-conditional on aggregation results
(Min/Max/Sum/Cardinality/Terms), guard SearchBeforeToken/AfterToken
and AggregationsExpression against null, fix OverageMiddleware null
dereference, add null guard in MessageBusBroker
- Tests: adapt all test assertions to handle nullable returns from
repository and aggregation APIs
* Fix Foundatio upgrade test failures
- Add .keyword sub-field to ip copy-to field in EventIndex so
FieldEquals validation passes (Foundatio now rejects TermQuery
on analyzed text fields without a keyword sub-field)
- Regenerate OpenAPI baseline to reflect updated CountResult schema
* Address Copilot review: fix remaining pre-canceled CancellationTokens
- Fix 3 work item handlers that still passed new CancellationToken(true)
to AcquireAsync, which would immediately cancel lock acquisition
- Replace unverified TODO with descriptive comment (tests pass)
* Use stack entity dates as fallback instead of DateTime.MinValue
Address Copilot review: fall back to stack.FirstOccurrence and
stack.LastOccurrence when aggregation metrics are null, instead
of leaking year-0001 timestamps to API consumers.
* Fix NRT correctness: restore non-blocking locks, remove hacks
Restore CancellationToken(true) in lock acquisition (17 files) — this is
intentional "try-once/non-blocking" semantics where AcquireAsync tries
once and returns null if the lock is held, causing the job/work item to
be retried later.
Replace String.Empty ParseConnectionString hacks with null-conditional
operator (7 files) — cleaner null handling via ?.ParseConnectionString() ?? [].
Remove unnecessary work item null checks (10 files) — Foundatio WorkItemJob
already validates non-null data before invoking handlers.
Update core Foundatio packages to 13.0.0-beta5.
* chore: upgrade Foundatio to beta6 and fix NRT annotations
* Fix null parse result handling: treat as failure, not valid
ParseAsync returns null on parse failure per Foundatio docs. Previously
this was incorrectly treated as valid (empty query). Now returns error
message in AppQueryValidator and explicit empty results in the filter
visitors instead of silently creating a GroupNode.
* pr feedback
* pr feedback
* PR Feedback
* pr feedback
* pr feedback
* pr feedback
* fixed build
* pr feedback
* pr feedback
* updated deps
* Fixed build
* The updated Foundatio now validates that FieldEquals (term query) cannot target analyzed text fields without a .keyword sub-field, because term queries on analyzed fields produce unexpected results (Elasticsearch stores lowercased tokens, not original text).
* Refactor filter query handling and update soft delete tests
Updated EventStackFilterQuery to handle null filter expressions without early returning, allowing the builder to continue execution. Additionally, updated StackRepositoryTests to verify that soft-deleted records are excluded from cache lookups by default.1 parent 5fb5034 commit fb4d951
94 files changed
Lines changed: 524 additions & 244 deletions
File tree
- src
- Exceptionless.Core
- Billing
- Configuration
- Extensions
- Jobs
- Elastic
- WorkItemHandlers
- Mail
- Migrations
- Models
- Collections
- Data
- Plugins/EventProcessor/Default
- Repositories
- Configuration/Indexes
- Interfaces
- Queries
- Validation
- Visitors
- Services
- Utility
- Exceptionless.Insulation
- Geo
- Mail
- Exceptionless.Web
- Controllers
- Hubs
- Utility
- Handlers
- tests/Exceptionless.Tests
- Controllers
- Data
- Jobs
- WorkItemHandlers
- Migrations
- Pipeline
- Repositories
- Search
- Serializer
- Services
- Stats
- Utility
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
| |||
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
0 commit comments