Skip to content

triggergate denies task_assigned triggers when the assigning actor is a service account #626

Closed

Description

@nsatee

Symptom

Assigning a ticket to an agent member via the API with a service-account API key moves the ticket to In Progress (assignment automation fires), but no task_assigned conversation is ever created. The API log shows:

notification consumer: TriggerTaskAssigned failed ... err="you don't have access to use this agent or its environment"

Assigning the same ticket from the UI as a human works, which makes this look like a permissions problem but it is a principal-mapping bug.

Root cause

services/api/internal/transport/triggergate/gate.go allow() builds the actor principal as:

principal := iam.User(member.UserID.String())
if member.MemberType == "agent" && member.AgentID != nil {
    principal = iam.Agent(member.AgentID.String())
}

For a service_account member, MemberType is neither handled nor is UserID populated (UserID is documented as "the account id for a human member, zero-value otherwise" — domain/project/member.go). The principal therefore becomes user/00000000-0000-0000-0000-000000000000, which matches no grant, so AllowedAll denies and every service-account-triggered assignment fails the gate.

The store side already supports this: repository/postgres/iam_store.go ListGrants resolves role attachments by ra.account_id regardless of account kind, and the authorizer explicitly accepts PrincipalServiceAccount (platform/authz/iam/check.go, authorizer.go:19). Only the gate mapping is missing.

Suggested patch

principal := iam.User(member.UserID.String())
switch {
case member.MemberType == "agent" && member.AgentID != nil:
    principal = iam.Agent(member.AgentID.String())
case member.MemberType == "service_account":
    principal = iam.ServiceAccount(member.AccountID.String())
}

plus a ServiceAccount(id string) constructor next to User/Agent in platform/authz/iam/check.go.

Workaround (until fixed)

Assign from the UI as a human, or perform the assignment call with a human user's API key — the gate passes for human members. Chat sessions (POST chat-sessions) are unaffected; they gate on project-level conversations:write.

Version observed: 0.19.0 (self-hosted).

Activity

  1. pullfrog commented on Oct 23, 2026

    @pullfrog
    Contributor
  2. self-assigned this
    on Oct 23, 2026
  3. pikann commented on Oct 23, 2026

    @pikann
    Contributor

    Thank you so much for pointing this out. I will fix it soon

  4. added
    bug
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions