Commit 0c0994c
Fix DbUpdateException handling in catalog import to prevent cascading failures (#412)
* Initial plan
* Fix DbUpdateException handling in catalog import
- Handle all DbUpdateException types, not just duplicate key violations
- Detach entities on any constraint violation to prevent cascading failures
- Add NOT NULL violation detection for better diagnostics
- Improve validation: check for whitespace-only PackageId values
- Add defensive validation for PackageIdLowered after setting
- All 18 tests pass
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>
* Add validation tests for null/whitespace PackageId
- Add 7 theory-based tests covering null, empty, and whitespace cases
- Verify both batch and individual processing paths throw InvalidOperationException
- All 25 tests pass
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>
* Fix duplicate logging placeholders
- Rename duplicate {PackageId} placeholder to {PackageIdValue}/{PackageVersionValue}
- Ensures all values are properly logged without ambiguity
- Addresses code review feedback
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>
* Address code review feedback
- Add IsConstraintViolationException() to detect all 23xxx constraint violations
- Rethrow non-constraint DbUpdateExceptions (timeouts, deadlocks) after detaching
- Remove unreachable defensive checks for PackageIdLowered (ToLowerInvariant never returns null)
- Simplify logging: remove redundant {PackageIdValue}/{PackageVersionValue} placeholders
- All 25 tests pass
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>
* Simplify null-conditional operator in IsConstraintViolationException
Use ?? false pattern for better clarity instead of == true
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bruno-garcia <1633368+bruno-garcia@users.noreply.github.com>1 parent 8708296 commit 0c0994c
2 files changed
Lines changed: 149 additions & 19 deletions
File tree
- src
- NuGetTrends.Scheduler.Tests
- NuGetTrends.Scheduler
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
471 | 526 | | |
472 | 527 | | |
473 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
16 | 30 | | |
17 | 31 | | |
18 | 32 | | |
| |||
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
117 | | - | |
| 131 | + | |
118 | 132 | | |
119 | 133 | | |
120 | | - | |
121 | | - | |
| 134 | + | |
| 135 | + | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
| |||
130 | 144 | | |
131 | 145 | | |
132 | 146 | | |
133 | | - | |
| 147 | + | |
134 | 148 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
138 | 177 | | |
139 | | - | |
| 178 | + | |
140 | 179 | | |
141 | 180 | | |
142 | 181 | | |
| |||
157 | 196 | | |
158 | 197 | | |
159 | 198 | | |
160 | | - | |
| 199 | + | |
161 | 200 | | |
162 | 201 | | |
163 | | - | |
164 | | - | |
| 202 | + | |
| 203 | + | |
165 | 204 | | |
166 | 205 | | |
167 | 206 | | |
| |||
171 | 210 | | |
172 | 211 | | |
173 | 212 | | |
174 | | - | |
| 213 | + | |
175 | 214 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 215 | + | |
179 | 216 | | |
180 | 217 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
185 | 249 | | |
186 | 250 | | |
187 | 251 | | |
| |||
191 | 255 | | |
192 | 256 | | |
193 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
194 | 269 | | |
195 | 270 | | |
196 | 271 | | |
| |||
0 commit comments