Commit 908f46f
authored
LEGLINK-887: Terminology FHIR endpoints return Problem Details on error (#1779)
* LEGLINK-887: Terminology FHIR endpoints return Problem Details on error
FhirController answered every error with a bare string body and text/plain, so a
rejected request carried no type, title, status or traceId. LEGLINK-886 corrected the
status code for a request naming no value set, but the payload was still a plain
string; this makes the body match the RFC 9457 format ConfigController has returned
since LEGLINK-591.
- Adds TerminologyProblem plus BadRequestProblem, NotFoundProblem and
InternalServerErrorProblem helpers, and routes all 13 error returns across the six
actions through them (7 BadRequest, 3 NotFound, 3 raw 500).
- traceId comes from the existing AddTerminologyProblemDetails customization.
- detail is prose, so the helper appends a terminating period. Exception messages stay
fragments because they are also read from logs and asserted in unit tests.
- 500 responses no longer place the exception message in the body; the customization
substitutes a generic detail so internal state is not exposed to the caller.
Testing: 73 unit tests pass in UnitTests.Terminology, one new covering LEGLINK-887's
reported request (empty valueUri in the POST body). Verified against the local
docker-compose stack that an empty valueUri in the body, an empty url query parameter,
a markup-only display and an unknown ValueSet id all return application/problem+json
carrying type, title, status, detail and a W3C traceId, and that the $validate-code
success and failure payloads are unchanged.
* LEGLINK-887: Cover the NotFound and 500 Problem Details contracts
Follow-up to review feedback on #1779: AssertBadRequestProblem was the only assertion
helper, so NotFoundProblem and InternalServerErrorProblem shipped untested.
- Generalises the helper to AssertProblem(result, status, title, type, detail) and keeps
AssertBadRequestProblem as a wrapper, leaving the existing call sites unchanged.
- Adds 404 coverage via GetValueSetById with an id the cache does not hold, and 500
coverage via a code group cached under the ValueSet type whose resource is a CodeSystem.
- Exercises the configured CustomizeProblemDetails callback directly, with no host and no
HTTP call, to assert a 5xx detail is replaced by the generic message and a traceId is
added. A paired client-error test pins the scrubbing to 5xx so an over-broad change
cannot silently erase the actionable 4xx detail this change exists to deliver.
The controller-level 500 test asserts status, title and type only: ProblemDetailsFactory
is null in unit tests, so ControllerBase.Problem builds a plain ProblemDetails and the
scrubbing belongs to the customization test.
Testing: 77 unit tests pass in UnitTests.Terminology, up from 73. Test project only; no
production code changed.1 parent e80df17 commit 908f46f
2 files changed
Lines changed: 188 additions & 21 deletions
File tree
- DotNet
- ServiceTests/UnitTests/Terminology/Controllers
- Terminology/Controllers
Lines changed: 141 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
56 | 89 | | |
57 | 90 | | |
58 | 91 | | |
| |||
99 | 132 | | |
100 | 133 | | |
101 | 134 | | |
102 | | - | |
103 | | - | |
| 135 | + | |
104 | 136 | | |
105 | 137 | | |
106 | 138 | | |
| |||
116 | 148 | | |
117 | 149 | | |
118 | 150 | | |
119 | | - | |
120 | | - | |
| 151 | + | |
121 | 152 | | |
122 | 153 | | |
123 | 154 | | |
| |||
127 | 158 | | |
128 | 159 | | |
129 | 160 | | |
130 | | - | |
131 | | - | |
| 161 | + | |
132 | 162 | | |
133 | 163 | | |
134 | 164 | | |
| |||
138 | 168 | | |
139 | 169 | | |
140 | 170 | | |
141 | | - | |
142 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 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 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
143 | 276 | | |
144 | 277 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
57 | 91 | | |
58 | 92 | | |
59 | 93 | | |
| |||
75 | 109 | | |
76 | 110 | | |
77 | 111 | | |
78 | | - | |
| 112 | + | |
79 | 113 | | |
80 | 114 | | |
81 | 115 | | |
82 | | - | |
| 116 | + | |
83 | 117 | | |
84 | 118 | | |
85 | 119 | | |
| |||
105 | 139 | | |
106 | 140 | | |
107 | 141 | | |
108 | | - | |
| 142 | + | |
109 | 143 | | |
110 | 144 | | |
111 | 145 | | |
112 | | - | |
| 146 | + | |
113 | 147 | | |
114 | 148 | | |
115 | 149 | | |
| |||
134 | 168 | | |
135 | 169 | | |
136 | 170 | | |
137 | | - | |
| 171 | + | |
138 | 172 | | |
139 | 173 | | |
140 | 174 | | |
141 | | - | |
| 175 | + | |
142 | 176 | | |
143 | 177 | | |
144 | 178 | | |
145 | | - | |
| 179 | + | |
146 | 180 | | |
147 | 181 | | |
148 | 182 | | |
| |||
168 | 202 | | |
169 | 203 | | |
170 | 204 | | |
171 | | - | |
| 205 | + | |
172 | 206 | | |
173 | 207 | | |
174 | 208 | | |
175 | | - | |
| 209 | + | |
176 | 210 | | |
177 | 211 | | |
178 | 212 | | |
| |||
198 | 232 | | |
199 | 233 | | |
200 | 234 | | |
201 | | - | |
| 235 | + | |
202 | 236 | | |
203 | 237 | | |
204 | 238 | | |
205 | | - | |
| 239 | + | |
206 | 240 | | |
207 | 241 | | |
208 | 242 | | |
| |||
235 | 269 | | |
236 | 270 | | |
237 | 271 | | |
238 | | - | |
| 272 | + | |
239 | 273 | | |
240 | 274 | | |
241 | 275 | | |
| |||
271 | 305 | | |
272 | 306 | | |
273 | 307 | | |
274 | | - | |
| 308 | + | |
275 | 309 | | |
276 | 310 | | |
277 | 311 | | |
| |||
0 commit comments