Description
- When running an Apify Actor twice in a row using
apify run -i 'some input', the first execution works as expected, but the second one fails to load the input - it returns None.
- It appears that metadata files from the previous run remain in local storage, preventing the new input from being correctly loaded.
Reproduction
Very simple Python Actor:
import asyncio
from apify import Actor
async def main() -> None:
async with Actor:
actor_input = await Actor.get_input()
Actor.log.info(f'Input: {actor_input}')
if __name__ == '__main__':
asyncio.run(main())
Execute it twice in a row:
uv run apify run -i '{ "days_reminder_long": 2000, "days_reminder_short": 2000, "days_urgent": 2000 }'
uv run apify run -i '{ "days_reminder_long": 2000, "days_reminder_short": 2000, "days_urgent": 2000 }'
Expected behavior
- Each run should receive the provided input, regardless of previous executions.
Actual behavior
- First run works correctly and logs the input.
- Second run logs
Input: None.
- It seems that leftover metadata files from the first run are not cleared and interfere with input loading.
Root cause and potential fix
- The SDK creates a metadata file for each INPUT file:
- If the CLI creates
INPUT.json, the SDK creates INPUT.json.__metadata__.json.
- If a user manually creates an
INPUT file (without extension), the SDK creates INPUT.__metadata__.json.
- The problem: when the CLI detects an existing
INPUT.json.__metadata__.json, it skips creating INPUT.json silently, resulting in a missing input and None being returned.
Additional context
- Related Slack discussion: link
Description
apify run -i 'some input', the first execution works as expected, but the second one fails to load the input - it returns None.Reproduction
Very simple Python Actor:
Execute it twice in a row:
Expected behavior
Actual behavior
Input: None.Root cause and potential fix
INPUT.json, the SDK createsINPUT.json.__metadata__.json.INPUTfile (without extension), the SDK createsINPUT.__metadata__.json.INPUT.json.__metadata__.json, it skips creatingINPUT.jsonsilently, resulting in a missing input andNonebeing returned.Additional context