Commit ff7de2b
committed
supply a valid $.Source in local execution's runtime context
@datadog/apps-backend's buildRuntimeFromJsFunctionWithActions is injected
into every backend function's bundle when that package is installed,
regardless of which specific function is called, and requires
$.Source.{initiator,runAsUser} to each be a User object with non-empty
id/orgId strings. Local execution's $ context never included Source,
so any app with @datadog/apps-backend installed (the create-apps scaffold
default) failed on its very first request -- not just functions that
call $.Actions, which was the only gap previously documented.
Confirmed by tracing the real, published package's bundled validation
logic and dd-source's production path: Source is populated upstream of
wf-actions-worker (the app-builder API layer, from the authenticated
caller's identity) before a bundled function ever runs -- it's plain
caller-supplied JSON by the time it reaches the script template, not a
server-signed value the runtime cross-checks. The validator only checks
shape (non-empty id/orgId strings), not a live session, so a synthetic
identity fully satisfies it.
Uses one placeholder identity for both initiator and runAsUser, since
on-behalf-of impersonation isn't meaningful when a single developer is
running their own code locally. No existing whoami-style endpoint exists
in this package's auth layer to fetch a real identity instead; real
identity resolution (if ever wanted) is a separate, non-blocking
enhancement, not a gap in this fix.
Verified against the real npm package (not a mock) via a new integration
test reusing the existing apps_backend_project fixture, and against a
real npm-linked scaffolded app calling getExecutionUser()/
getInitiatingUser() through /__dd/executeAction.1 parent 2a864e8 commit ff7de2b
2 files changed
Lines changed: 65 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
74 | 90 | | |
75 | 91 | | |
76 | 92 | | |
77 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
78 | 98 | | |
79 | 99 | | |
80 | 100 | | |
| |||
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
247 | 247 | | |
248 | 248 | | |
249 | 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 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
250 | 293 | | |
0 commit comments