Skip to content

fix(cli): isolate trigger runs from interactive user ids - #8239

Open
Skull-boy wants to merge 3 commits into
google:mainfrom
Skull-boy:fix/trigger-user-id-namespace
Open

Skull-boy wants to merge 3 commits into
google:mainfrom
Skull-boy:fix/trigger-user-id-namespace

Conversation

@Skull-boy

Copy link
Copy Markdown

Problem:

/apps/{app}/trigger/pubsub and /apps/{app}/trigger/eventarc turned the request's subscription or source field into the run's user_id. A caller could set that field to an existing user id such as alice, and the run would read and write alice's user: state, artifacts, and memory.

Solution:

Trigger runs now always use a dedicated trigger--<trigger>--<metadata> user namespace. Both endpoints share the same helper, including Eventarc's ce-source header path. The request and response contracts are unchanged; the request body simply can no longer name an interactive user.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

pytest tests/unittests/cli/test_trigger_routes.py tests/unittests/cli/test_trigger_auth.py -q -> 113 passed.

The new tests cover Pub/Sub subscription: "alice", Eventarc source: "alice", and Eventarc ce-source: alice. In each case the agent's user:note write lands in the trigger namespace while alice's existing user:secret state is unchanged. Existing valid subscription/source tests still pass with the new namespaced ids.

Manual End-to-End (E2E) Tests:

Offline reproduction with get_fast_api_app, a model-free agent that writes user:note, and an accept-any-bearer-token verifier:

  • Before: the run used user_id='alice', read alice-secret-4711, and wrote user:note into alice's state.
  • After: the run used user_id='trigger--pubsub--alice', read no user secret, and alice's state stayed {'secret': 'alice-secret-4711'}.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

ruff, isort, pyink, and mypy all pass on the modified files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger endpoints take the run's user_id from the request body, so a trigger request can run as (and write into) any existing user

2 participants