Commit 3e4ad0b
fix(data-access): return plain camelCase object from allByOrganizationIds*WithTargetOrganization
#fetchGrantsWithTargetOrg was calling createInstanceFromRow(), producing a
model instance for the `grant` field. The auth-service (and the method's own
docstring) expected a plain camelCase object with direct property access
(grant.productCode, grant.expiresAt, grant.organizationId, …). On a model
instance those fields are undefined; only getters like getProductCode() exist.
This caused the delegated_tenants loop to skip every grant because
`grant.productCode !== productCode` was always `undefined !== 'LLMO'` → true,
leaving delegated_tenants: [] in every JWT regardless of real DB grants.
Fix: destructure the embedded `organizations` key from the PostgREST row,
then call fromDbRecord(grantRow, this.fieldMaps.toModelMap) to produce the
documented plain camelCase object.
Update unit and IT tests to assert direct property access (grant.organizationId,
grant.productCode, …) instead of model-instance getters, so the contract is
verified at the test level going forward.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 3b7d348 commit 3e4ad0b
File tree
3 files changed
+27
-19
lines changed3 files changed
+27
-19
lines changedLines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| |||
356 | 359 | | |
357 | 360 | | |
358 | 361 | | |
359 | | - | |
| 362 | + | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
| |||
0 commit comments