Repository navigation
Commit 90caf84
cli/cloud: fix
## Summary
`scan log --all` doesn't paginate to the end; and step mode comes back
empty."
The Insights scan-logs endpoint and the Pulumi Deployments logs endpoint
are served by the same server handler. The insights apitype had drifted
away from that shape, which is the whole reason the bugs existed.
**What this PR copies from
[`apitype.DeploymentLogs`](sdk/go/common/apitype/deployments.go#L351-L354)
/ [`deployment_log.go`](pkg/cmd/pulumi/deployment/deployment_log.go):**
- The response field is `NextToken` with `json:"nextToken,omitempty"` —
matches what the server emits.
- Step mode returns a `Lines` array (not a raw `Output` string).
- The `--all` loop terminates only when the server emits an empty
cursor.
### Bug 1 — continuation mode (`--all`)
The server emits `nextToken` on the wire but
[`apitype.InsightsScanLogs`](sdk/go/common/apitype/insights.go) had the
field tagged `continuationToken`. The struct field decoded to `""` on
every response, so the page loop terminated after the first page.
Renamed `ContinuationToken` → `NextToken` with the matching JSON tag —
same shape as
[`apitype.DeploymentLogs`](sdk/go/common/apitype/deployments.go), which
is the same server handler.
### Bug 2 — step mode (`--job N --step M`)
The server returns `{lines: [{timestamp, line}, …]}` in step mode too —
same envelope as continuation mode, just scoped to one step, with
`nextOffset` (an int line index) instead of `nextToken`. The previous
step renderer wrote `r.Output` (a never-populated string field), so the
command printed nothing. Dropped the dead `Output` field; both modes now
share one line-oriented renderer.
`--all` in step mode follows the `nextOffset` chain to accumulate every
page of lines.
**What this PR deliberately does NOT copy from Deployments:**
- The `--count` / `--all` semantics on `insights account scan log` are
kept as-is (matching the rest of the Cloud-Ready Insights CLI surface —
`account list`, `account scan list`).
- The `--org` + positional `<account>` scoping stays — Insights scopes
by account, deployments scope by stack.
## Follow-up worth considering (not in this PR)
`apitype.DeploymentLogs` and `apitype.InsightsScanLogs` are now
literally the same shape (`Lines []…`, `NextToken string`, plus
step-mode `NextOffset int64`). They could be unified into a single
`apitype.WorkflowLogs` struct shared between the two endpoints.
Similarly, the `--all` loops in
[`deployment_log.go`](pkg/cmd/pulumi/deployment/deployment_log.go) and
[`insights_account_scan_log.go`](pkg/cmd/pulumi/insights/insights_account_scan_log.go)
are nearly identical and could share a helper. Both would be refactors
that should touch deployments and insights together, not be smuggled
into a bug fix.
## Sample output (before / after)
### `--all` continuation mode
```
# Before: stops after one page (~100 lines)
$ pulumi insights account scan log "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi --all | wc -l
100
# After: follows the cursor to the end
$ pulumi insights account scan log "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi --all | wc -l
8099
```
### `--job N --step M --all` step mode
```
# Before: empty output
$ pulumi insights account scan log "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi --job 0 --step 0 --all
(empty)
# After: prints the step's log lines and follows nextOffset
$ pulumi insights account scan log "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi --job 0 --step 0 --all
2026-01-21T15:59:15Z Preparing environment
2026-01-21T15:59:17Z Using runner default image with Pulumi version 3.216.0 …
2026-01-21T15:59:17Z Starting container
2026-01-21T15:59:26Z Container created …
2026-01-21T15:59:26Z Container started …
…
```
For a step whose log spans multiple `nextOffset` pages (step 3 in the
example above), `--all` now fetches the full content:
```
$ pulumi insights account scan log "Michael-Test-AWS/us-east-2" 7bb80f16-… --org pulumi --job 0 --step 3 --all | wc -l
8081
```
## Test plan
- [x] Updated unit tests for both modes to use the real server response
shape (`lines` array in step mode, `nextToken` in continuation mode).
- [x] Updated
[`client_insights_test.go`](pkg/backend/httpstate/client/client_insights_test.go)
to round-trip the same shape.
- [x] `mise exec -- make format`
- [x] `mise exec -- make lint` (0 issues across 7 packages)
- [x] Live smoke against the `pulumi` org: continuation `--all` returns
8099 lines (was ~100), step-mode `--job 0 --step 0 --all` returns the
step's log content (was empty), step 3 `--all` fetches 8081 lines across
multiple `nextOffset` pages.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>pulumi insights account scan log pagination (#23256)1 parent 89c75c0 commit 90caf84
5 files changed
Lines changed: 79 additions & 63 deletions
File tree
- changelog/pending
- pkg
- backend/httpstate/client
- cmd/pulumi/insights
- sdk/go/common/apitype
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
| 571 | + | |
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
592 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
593 | 598 | | |
594 | 599 | | |
595 | 600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
226 | | - | |
| 225 | + | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
232 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| |||
242 | 246 | | |
243 | 247 | | |
244 | 248 | | |
245 | | - | |
| 249 | + | |
246 | 250 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
254 | | - | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
256 | 259 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | 260 | | |
280 | 261 | | |
281 | 262 | | |
| |||
300 | 281 | | |
301 | 282 | | |
302 | 283 | | |
303 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
304 | 289 | | |
305 | 290 | | |
306 | 291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
106 | 123 | | |
107 | 124 | | |
108 | 125 | | |
| |||
266 | 283 | | |
267 | 284 | | |
268 | 285 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 286 | + | |
274 | 287 | | |
275 | 288 | | |
276 | 289 | | |
| |||
289 | 302 | | |
290 | 303 | | |
291 | 304 | | |
292 | | - | |
| 305 | + | |
| 306 | + | |
293 | 307 | | |
294 | 308 | | |
295 | 309 | | |
| |||
298 | 312 | | |
299 | 313 | | |
300 | 314 | | |
301 | | - | |
302 | | - | |
303 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
304 | 318 | | |
305 | 319 | | |
306 | 320 | | |
| |||
326 | 340 | | |
327 | 341 | | |
328 | 342 | | |
329 | | - | |
330 | | - | |
331 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
332 | 349 | | |
333 | 350 | | |
334 | 351 | | |
| |||
469 | 486 | | |
470 | 487 | | |
471 | 488 | | |
472 | | - | |
473 | | - | |
474 | | - | |
| 489 | + | |
475 | 490 | | |
476 | 491 | | |
477 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
384 | 392 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
390 | 397 | | |
391 | 398 | | |
392 | 399 | | |
| |||
0 commit comments