Skip to content

fix(actors ls): do not crash when an Actor record has no stats - #1435

Open
l2ysho wants to merge 2 commits into
masterfrom
fix/actors-ls-missing-actor-stats
Open

l2ysho wants to merge 2 commits into
masterfrom
fix/actors-ls-missing-actor-stats

Conversation

@l2ysho

@l2ysho l2ysho commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Note

apify actors ls crashed with Cannot read properties of undefined (reading 'totalBuilds'). The stats field is missing on some Actor records; the code only guarded item.actor. One-line guard plus a regression test.

What changed

  • src/commands/actors/ls.tsitem.actor ? …item.actor?.stats ? … for the Builds column.
  • test/local/commands/actors-ls.test.ts — renders the table with an Actor record that has no stats. Fails on master with the exact error above.

Why it happened

  • apify-client types Actor.stats as required (ActorStats), so TypeScript saw the access as safe. The API does not always send it.
  • The Builds value is computed for both tables even though only the --my table shows that column, so plain apify actors ls hits it too.
  • Existing e2e tests all pass --json, which returns before table rendering. The render path had no coverage.

Notes

  • Not reproducible on every account — depends on which Actors are in your recent list.
  • apify-client's ActorStats is inaccurate in two more ways: totalMetamorphs is required but absent from 3 of 5 public Actor responses I checked, and publicActorRunStats30Days, actorReviewCount, actorReviewRating, bookmarkCount are returned but undeclared. Worth a separate issue on apify-client-js.
  • No install-size impact.

Reported by @mtrunkat in #cli.

🤖 Generated with Claude Code

`apify actors ls` read `item.actor.stats.totalBuilds` behind an
`item.actor` null check only. The API omits `stats` on some Actor
records, so the command exited with
`Cannot read properties of undefined (reading 'totalBuilds')`.

apify-client types `Actor.stats` as required, so TypeScript did not
flag it. The e2e tests all pass `--json`, which returns before the
table is rendered, so the path was untested.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@l2ysho
l2ysho marked this pull request as ready for review September 11, 2026 15:20
@l2ysho
l2ysho requested a review from DaveHanns as a code owner September 11, 2026 15:20
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Sep 11, 2026
@apify-service-account apify-service-account added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 11, 2026
@l2ysho l2ysho added adhoc Ad-hoc unplanned task added during the sprint. t-builders Issues owned by the Builders team. and removed t-tooling Issues with this label are in the ownership of the tooling team. labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-builders Issues owned by the Builders team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants