You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove deprecated robot account middleware and CurrentRobotAccount context helper #3122
Robot accounts are deprecated in favor of API tokens, but the legacy CurrentRobotAccount(ctx) accessor (and its supporting middleware) still sits in usercontext and is the principal consumers read from across the attestation path. It survives only because of two compatibility bridges that stuff a partial RobotAccount into the context whenever the real principal is an API token or a user JWT.
The result is misleading code: callers think they're holding a robot account, but most of the fields on that struct are empty for the principals that actually drive traffic today.
Goal
Remove the deprecated robot account middleware and the CurrentRobotAccount helper, and migrate consumers to the proper accessors — entities.CurrentOrg(ctx) for the organization and entities.CurrentAPIToken(ctx) (nil-guarded) for API-token-specific claims.
Caveats — how CurrentRobotAccount(ctx) actually behaves today
The RobotAccount struct has four fields (ID, WorkflowID, OrgID, ProviderKey), but only the legacy real-robot-account path fills all of them in. Both compatibility bridges only populate OrgID and ProviderKey:
Principal
ID
WorkflowID
OrgID
ProviderKey
Robot account (legacy)
yes
yes
yes
RobotAccountProviderKey
API token
empty
empty
yes
APITokenProviderKey
User JWT (attestation)
empty
empty
yes
UserTokenProviderKey
Consequences any migration needs to handle:
Only OrgID and ProviderKey are safe to read from CurrentRobotAccount(ctx). Reading ID or WorkflowID silently returns the zero value for two of the three principals.
entities.CurrentAPIToken(ctx) is only set when the principal is an API token. A naive swap of CurrentRobotAccount for CurrentAPIToken breaks user-token attestation flows (e.g., chainloop attestation init after chainloop auth login). We hit this regression in fix(controlplane): allow workflow-scoped API tokens in find-or-create #3123 — see that PR's iteration history.
There is no single drop-in replacement. The right replacement depends on what each call site actually needs:
Org → entities.CurrentOrg(ctx) (populated for all three principals).
API-token-specific claims (workflow scope, project scope, policies) → entities.CurrentAPIToken(ctx), guarded by a != nil check.
Robot-account ID / Workflow ID → only the real-robot-account path has these; for the other two, derive workflow/project info from the request or from entities.CurrentAPIToken claims.
Tests should explicitly cover the user-token path — this is the principal where regressions are easy to miss because it goes through neither of the two obvious middlewares (*RobotAccount* and *APIToken*).
Out of scope
Removing the RobotAccountUseCase business logic and DB schema (handled separately as part of the broader robot account deprecation).
Before implementing this, could you clarify the intended compatibility boundary for legacy robot-account JWTs?
Should legacy robot-account tokens continue authenticating after this change, with the current robot-account middleware refactored to populate entities.CurrentOrg(ctx) and derive workflow information from claims/request data, or should this remove legacy robot-token authentication entirely? The issue scopes removal of RobotAccountUseCase and the robot-account database schema separately, so I want to avoid breaking existing tokens unintentionally.
Also, current main has three withRobotAccount compatibility bridges:
Activity
waveywaves commentedon Jun 6, 2026
/assign
waveywaves commentedon Jul 14, 2026
Before implementing this, could you clarify the intended compatibility boundary for legacy robot-account JWTs?
Should legacy robot-account tokens continue authenticating after this change, with the current robot-account middleware refactored to populate
entities.CurrentOrg(ctx)and derive workflow information from claims/request data, or should this remove legacy robot-token authentication entirely? The issue scopes removal ofRobotAccountUseCaseand the robot-account database schema separately, so I want to avoid breaking existing tokens unintentionally.Also, current
mainhas threewithRobotAccountcompatibility bridges:The issue mentions two. Should removal include the federated bridge as well?
github-actions commentedon Sep 13, 2026
This issue is stale because it has been open for 60 days with no activity. It will be closed in 7 days if no further activity occurs.
github-actions commentedon Sep 21, 2026
This issue was closed because it has been inactive for 7 days since being marked as stale. Feel free to reopen if it is still relevant.