Commit f72f0db
fix(artifacts): namespace file artifacts by app
FileArtifactService stored every artifact under `root/users/{user_id}`,
dropping app_name from the path entirely. Two apps served from one root
therefore shared a single artifact namespace: saving `report.txt` from one app
overwrote the other app's `report.txt`, and load, list, delete and the version
APIs all returned the other app's data. The in-memory and GCS services already
key on app_name, so the file service was the odd one out.
app_name is now threaded through all seven public methods, and artifacts live
under `root/apps/{app_name}/users/{user_id}/...` to match the other services.
app_name is validated as a path segment the way user_id and session_id already
are, so the file service now runs the same traversal tests as the other two
services.
The pre-app-scoped `root/users` tree is still read when the app-scoped location
holds nothing. That is not only for in-place upgrades: the CLI's per-agent
artifact storage already ships a fallback that points a FileArtifactService at
the shared `.adk/artifacts` folder, whose entire contents are in the
pre-app-scoped layout, so dropping the read would silently break an existing
migration path. Saves only ever go to the app-scoped location, and deleting an
artifact removes both copies.
Backward-compatibility notes, both limited to data written before this change:
- Artifacts already under `root/users` stay readable by every app sharing that
root, and a delete from any one of those apps removes them for all of them,
because that layout records no owner. Isolation is complete for artifacts
written from this release onwards. The CLI is unaffected: it gives each agent
its own root, so a given root's `root/users` tree only ever held one agent's
artifacts.
- The first save of such an artifact restarts version numbering in the
app-scoped location and stops serving the older versions, which stay on disk
until the artifact is deleted.
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 9547874181 parent c59fd0e commit f72f0db
3 files changed
Lines changed: 350 additions & 96 deletions
File tree
- src/google/adk/artifacts
- tests/unittests
- artifacts
- cli/utils
0 commit comments