google / google/adk-js

adk run --replay does not validate the input file

Open
#721 0 comments 0 reactions 1 assignee Claimed by @Varun-S10 View on GitHub
Dominant language
TypeScript
Stars
1.4k
Forks
205
Avg merge
3d 12h
Merged PRs (30d)
98

Description

`loadFileData` is an unchecked cast (`dev/src/cli/cli_run.ts:161`), so a hand-written replay file fails inside CLI internals instead of being rejected. The worst case is silent: `"queries": "hi"` is iterated character by character, billing one full workflow invocation per letter and exiting 0.

```bash
cd dev
echo '{"queries":["go"]}' > /tmp/a.json # missing "state"
echo '{"state":{}}' > /tmp/b.json # missing "queries"
echo '{"state":{},"queries":"hi"}' > /tmp/c.json # queries is a string
for f in a b c; do npx adk run --replay /tmp/$f.json ../samples/workflows/graphs/get_started/agent.ts; done
```

```
a -> [ADK CLI] Error running agent: Cannot set properties of undefined (setting '_time') (cli_run.ts:168)
b -> [ADK CLI] Error running agent: fileContent.queries is not iterable (cli_run.ts:179)
c -> [user]: h ... [user]: i two complete runs, four model calls, exit 0
```

`_time` is a key the CLI injects, not something the user wrote. The nonexistent-file path already produces a good message (`Failed to read or parse file /tmp/nope.json: ENOENT...`); malformed content should get the same treatment.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.