Skip to content

Breaking change? Missing runTimeSecs in stats of the actor run #655

@honzajavorek

Description

@honzajavorek

I don't know where to file this, as it's probably a bug in the API, but I experience it through the SDK, so I guess this is the best place for me.

actor = client.actor(actor_name)
last_run = actor.last_run(status=ActorJobStatus.SUCCEEDED)
run_info = last_run.get()
if run_info is None:
    if raise_if_missing:
        raise RuntimeError(f"No successful runs of {actor_name!r} found")
    logger.error(f"No successful runs of {actor_name!r} found")
    return []
run_url = (
    f"https://console.apify.com/actors/{run_info['actId']}/runs/{run_info['id']}"
)
logger.debug(
    f"Last successful run of {actor_name}: {run_url}, "
    f"finished {run_info['finishedAt']}, "
    f"took {run_info['stats']['runTimeSecs']}s"
)
dataset = last_run.dataset()

This code has worked yesterday and it doesn't work today. I get

KeyError: 'runTimeSecs'

When I print what's in run_info, I get this:

{'id': 'DYdVuJJ3gZx0dp8wo', 'actId': 'hKByXkMQaC5Qt9UMN', 'userId': 'MdyLmQ25h82gno3Ab', 'startedAt': datetime.datetime(2025, 10, 30, 1, 11, 1, 10000, tzinfo=datetime.timezone.utc), 'finishedAt': datetime.datetime(2025, 10, 30, 1, 18, 14, 467000, tzinfo=datetime.timezone.utc), 'status': 'SUCCEEDED', 'meta': {'origin': 'SCHEDULER', 'scheduleId': 'RImSttfouf0jSbXoo', 'scheduledAct2Id': 'FqDKXTn0Dghx6JVEy', 'scheduledAt': datetime.datetime(2025, 10, 30, 1, 11, tzinfo=datetime.timezone.utc)}, 'stats': {'resurrectCount': 0, 'restartCount': 0, 'computeUnits': 0}, 'options': {'build': 'latest', 'timeoutSecs': 3600, 'memoryMbytes': 1024, 'maxItems': 173868, 'diskMbytes': 2048}, 'buildId': 'e1FCvitdLiTXeVtWO', 'exitCode': 0, 'defaultKeyValueStoreId': 'Pxeob9IkWb0J3LH3K', 'defaultDatasetId': 'ZlGrPg5kjoayN5XoH', 'defaultRequestQueueId': '4T1e4uKve9nFiZRgS', 'pricingInfo': {'pricingModel': 'PRICE_PER_DATASET_ITEM', 'reasonForChange': None, 'pricePerUnitUsd': 0.001, 'unitName': 'result', 'createdAt': datetime.datetime(2024, 8, 27, 13, 37, 42, 429000, tzinfo=datetime.timezone.utc), 'startedAt': datetime.datetime(2024, 8, 27, 13, 37, 42, 429000, tzinfo=datetime.timezone.utc), 'apifyMarginPercentage': 0.2, 'notifiedAboutChangeAt': datetime.datetime(2024, 8, 27, 13, 39, 17, 506000, tzinfo=datetime.timezone.utc)}, 'platformUsageBillingModel': 'DEVELOPER', 'generalAccess': 'FOLLOW_USER_SETTING', 'buildNumber': '1.0.114', 'containerUrl': 'https://rcfmcz3tn7nr.runs.apify.net', 'consoleUrl': 'https://console.apify.com/view/runs/DYdVuJJ3gZx0dp8wo'}

I guess the workaround is to do run_info['finishedAt'] - run_info['startedAt'], but the fact that the runTimeSecs is missing feels like an unintended or not well communicated breaking change. Maybe I'm just a victim of the Hyrum's Law? 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions