Commit 87b47f4
fix(analytics): fail closed on cross-object aggregation the ObjectQL path cannot join (#3654)
engine.aggregate() has no join — it never expands a lookup and the SQL
driver's aggregate emits no JOIN. A dotted dimension/measure like
account.region reaching ObjectQLStrategy (the fallback NativeSQL declines
on: date-granularity bucketing, in-memory driver, federated objects)
failed SILENTLY: the in-memory path bucketed every row under one (null)
group and summed the whole table into it — a plausible number that is
actually a mislabelled full-table total; the native path errored on the
unresolved column.
ObjectQLStrategy now rejects any cross-object reference outright, with a
clear message, before the query reaches the engine. This generalizes the
#3597 guard (assertJoinedScopesEnforceable), which only rejected when the
joined object carried a read scope AND early-returned when no read-scope
provider was configured — so the silent (null) bucket still shipped on
unsecured / in-memory setups. The new guard is unconditional and subsumes
#3597: a rejected query never loads the joined object, so nothing is left
unscoped.
Cross-object datasets are unaffected on NativeSQLStrategy, which
hand-compiles the LEFT JOINs (and scopes each). This only changes the
fallback path — a silent wrong answer becomes a loud, actionable error.
Full lookup-traversal in the aggregate path is left as follow-up (#3654).
Tests: three cross-object cases (joined-object scope / base-only scope /
NO provider — the #3654 silent-(null) case) now reject; reverting the
guard turns all three red. The engine-level in-memory repro is in #3654.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 415254c commit 87b47f4
3 files changed
Lines changed: 101 additions & 49 deletions
File tree
- .changeset
- packages/services/service-analytics/src
- __tests__
- strategies
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 27 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
234 | 237 | | |
235 | 238 | | |
236 | | - | |
237 | | - | |
| 239 | + | |
| 240 | + | |
238 | 241 | | |
239 | 242 | | |
| 243 | + | |
240 | 244 | | |
241 | 245 | | |
242 | | - | |
243 | | - | |
| 246 | + | |
244 | 247 | | |
245 | | - | |
246 | | - | |
247 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
248 | 254 | | |
249 | 255 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
254 | 260 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
258 | 268 | | |
259 | 269 | | |
Lines changed: 48 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
| |||
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
188 | | - | |
| 195 | + | |
| 196 | + | |
189 | 197 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
194 | 207 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
199 | 215 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
203 | 219 | | |
204 | | - | |
| 220 | + | |
205 | 221 | | |
206 | 222 | | |
207 | 223 | | |
208 | 224 | | |
209 | | - | |
210 | 225 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
215 | 229 | | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
| 235 | + | |
221 | 236 | | |
222 | 237 | | |
223 | 238 | | |
224 | 239 | | |
225 | 240 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 241 | + | |
| 242 | + | |
229 | 243 | | |
230 | 244 | | |
231 | 245 | | |
232 | 246 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
240 | 256 | | |
241 | 257 | | |
242 | 258 | | |
| |||
0 commit comments