Bug: CreateGroup via PAT creates an orphan group row
メンテナーはふだん 1 日以内に返信
@AmanGIT07 がすでに取り組んでいます。
2026年5月25日 から。
評価
この issue はまだ評価されていません。
説明
Summary
When CreateGroup is called by a PAT-authenticated principal, the Postgres groups row is written but the SpiceDB hierarchy links and owner policy are never wired. The row is left as an orphan.
Reproduction
- Authenticate as a PAT scoped to an org with the create-group permission.
- Call
CreateGroup. - Observe: response carries an error; a row exists in
groupsfor the requested name; SpiceDB has nogroup#org/org#member@grouprelations and no owner policy inpolicies.
Root cause
core/group/service.go:72-74—s.repository.Create(ctx, grp)writes the Postgres row first.core/group/service.go:77—s.membershipService.OnGroupCreated(ctx, newGroup.ID, newGroup.OrganizationID, principal.ID, principal.Type)passes the raw principal. For PAT auth this is(<pat-id>, "app/pat").core/membership/service.go:1302—OnGroupCreatedcallsSetGroupMemberRole(..., creatorID, creatorType, schema.GroupOwnerRole).core/membership/service.go:1402-1420—validateGroupPrincipalswitches on principal type and accepts onlyapp/user; everything else returnsErrInvalidPrincipalType.- The error propagates back to the group
Createcaller, butrepository.Createis not rolled back.
Impact
- Orphan rows accumulate in
groupson each failed PAT-drivenCreateGroupcall. - The orphan has no hierarchy in SpiceDB, no owner policy in Postgres, and is unreachable through normal listing (membership-based listing won't surface it either, since there's no policy row).
Suggested fix
Resolve the PAT to its underlying user before invoking OnGroupCreated, mirroring the pattern in CreateProject at core/project/service.go:113:
principal, err := s.authnService.GetPrincipal(ctx)
if err != nil {
return Group{}, fmt.Errorf("%w: %s", authenticate.ErrInvalidID, err.Error())
}
...
subjectID, subjectType := principal.ResolveSubject() // PAT → user
if err = s.membershipService.OnGroupCreated(ctx, newGroup.ID, newGroup.OrganizationID, subjectID, subjectType); err != nil {
return Group{}, err
}
Two-line change. Independent of the ListByUser → List migration in #1643 (this bug pre-dates that work).
Cleanup
Existing orphan rows should be identified and either backfilled with hierarchy + owner or deleted. Candidate query: groups whose id has no matching row in policies with resource_type = 'app/group'.
How surfaced
Found while testing the group listing migration in #1643 with PAT-authenticated calls. The listing bug there was fixed in 42a5c508; this write-side bug is independent.
- 主要言語
- Go
- スター
- 344
- フォーク
- 48
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
raystack/frontier のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
Deleting an organization that has a disabled project fails and leaves it without owners対応中かも @rohilsurana が 5 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
raystack/frontier の issue をすべて見る
似ている issue
-
agent-review-finding bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jordansmall/spindrift#5281 ·
メンテナーはふだん 1 日以内に返信
-
unbounded value for n in `/v1/logs` can panic/OOM対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンsmall item
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
canonical/pebble#1127 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[schema-coverage] elasticstack_elasticsearch_synonym_set (data source)対応中かも @github-actions が今日担当しました。 オープンacceptance-tests phase-coding schema-coverage testing triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 81/100
elastic/terraform-provider-elasticstack#5211 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 89/100
open-policy-agent/opa#9366 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
defect
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nats-io/nats-server#8752 ·
メンテナーはふだん 1 日以内に返信