Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: user id format in project and sheet (#6155)

p0ny08b4364c743a
diff --git a/backend/api/v1/common.go b/backend/api/v1/common.go
index 0302f11b64..00ffb6cb01 100644
--- a/backend/api/v1/common.go
+++ b/backend/api/v1/common.go
@@ -596,13 +596,3 @@ func convertEngine(engine v1pb.Engine) db.Type {
}
return db.UnknownType
}
-
-// getUserIdentifier returns the user identifier.
-// See more details in project_service.proto.
-func getUserIdentifier(email string) string {
- return "user:" + email
-}
-
-func getUserEmailFromIdentifier(ident string) string {
- return strings.TrimPrefix(ident, "user:")
-}
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 358586080d..f314fd7ae0 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -832,7 +832,7 @@ func convertToIamPolicy(iamPolicy *store.IAMPolicyMessage) *v1pb.IamPolicy {
for _, binding := range iamPolicy.Bindings {
var members []string
for _, member := range binding.Members {
- members = append(members, getUserIdentifier(member.Email))
+ members = append(members, fmt.Sprintf("user:%s", member.Email))
}
bindings = append(bindings, &v1pb.Binding{
Role: convertToProjectRole(binding.Role),
@@ -855,7 +855,7 @@ func (s *ProjectService) convertToIAMPolicyMessage(ctx context.Context, iamPolic
return nil, status.Errorf(codes.InvalidArgument, err.Error())
}
for _, member := range binding.Members {
- email := getUserEmailFromIdentifier(member)
+ email := strings.TrimPrefix(member, "user:")
user, err := s.store.GetUser(ctx, &store.FindUserMessage{
Email: &email,
ShowDeleted: true,
diff --git a/backend/api/v1/review_service.go b/backend/api/v1/review_service.go
index 4ab2c30ff6..ed1d3d9834 100644
--- a/backend/api/v1/review_service.go
+++ b/backend/api/v1/review_service.go
@@ -419,7 +419,7 @@ func convertToReview(ctx context.Context, s *store.Store, issue *store.IssueMess
if err != nil {
return nil, errors.Wrapf(err, "failed to find user by id %v", approver.PrincipalId)
}
- convertedApprover.Principal = fmt.Sprintf("%s%s", userNamePrefix, user.Email)
+ convertedApprover.Principal = fmt.Sprintf("users/%s", user.Email)
review.Approvers = append(review.Approvers, convertedApprover)
}
}
diff --git a/backend/api/v1/sheet_service.go b/backend/api/v1/sheet_service.go
index 1f14ccb8cd..907610c3d7 100644
--- a/backend/api/v1/sheet_service.go
+++ b/backend/api/v1/sheet_service.go
@@ -188,7 +188,7 @@ func (s *SheetService) SearchSheets(ctx context.Context, request *v1pb.SearchShe
for _, spec := range specs {
switch spec.key {
case "creator":
- creatorEmail := getUserEmailFromIdentifier(spec.value)
+ creatorEmail := strings.TrimPrefix(spec.value, "users/")
if creatorEmail == "" {
return nil, status.Errorf(codes.InvalidArgument, "invalid empty creator identifier")
}
@@ -652,7 +652,7 @@ func (s *SheetService) convertToAPISheetMessage(ctx context.Context, sheet *stor
Name: fmt.Sprintf("%s%s/%s%d", projectNamePrefix, project.ResourceID, sheetIDPrefix, sheet.UID),
Database: databaseParent,
Title: sheet.Name,
- Creator: getUserIdentifier(creator.Email),
+ Creator: fmt.Sprintf("users/%s", creator.Email),
CreateTime: timestamppb.New(sheet.CreatedTime),
UpdateTime: timestamppb.New(sheet.UpdatedTime),
Content: []byte(sheet.Statement),
diff --git a/frontend/src/types/proto/v1/logging_service.ts b/frontend/src/types/proto/v1/logging_service.ts
index 31d92d690b..972b7b25a9 100644
--- a/frontend/src/types/proto/v1/logging_service.ts
+++ b/frontend/src/types/proto/v1/logging_service.ts
@@ -54,7 +54,7 @@ export interface ListLogsResponse {
export interface LogEntry {
/**
* The creator of the log entry.
- * Format: user:{emailid}
+ * Format: users/{emailid}
*/
creator: string;
/** The timestamp when the backup resource was created initally. */
@@ -66,7 +66,7 @@ export interface LogEntry {
/**
* The name of the resource associated with this log entry. For example, the resource user associated with log entry type of "ACTION_MEMBER_CREATE".
* Format:
- * For ACTION_MEMBER_*: user:emailid
+ * For ACTION_MEMBER_*: users/{email}
* For ACTION_ISSUE_*: issues/{issue}
* For ACTION_PIPELINE_*: pipelines/{pipeline}
* For ACTION_PROJECT_*: projects/{project}
diff --git a/frontend/src/types/proto/v1/review_service.ts b/frontend/src/types/proto/v1/review_service.ts
index b4f542e7ef..b36c935538 100644
--- a/frontend/src/types/proto/v1/review_service.ts
+++ b/frontend/src/types/proto/v1/review_service.ts
@@ -158,7 +158,7 @@ export interface Review {
approvalFindingError: string;
/**
* The subscribers.
- * Format: user:[email protected]
+ * Format: users/[email protected]
*/
subscribers: string[];
/** Format: users/[email protected] */
diff --git a/frontend/src/types/proto/v1/sheet_service.ts b/frontend/src/types/proto/v1/sheet_service.ts
index 64d53e256d..a3d3ea0216 100644
--- a/frontend/src/types/proto/v1/sheet_service.ts
+++ b/frontend/src/types/proto/v1/sheet_service.ts
@@ -66,7 +66,7 @@ export interface SearchSheetsRequest {
/**
* To filter the search result.
* Format: only support the following spec for now:
- * - `creator = user:{email}`, `creator != user:{email}`
+ * - `creator = users/{email}`, `creator != users/{email}`
* - `starred = true`, `starred = false`.
* Not support empty filter for now.
*/
@@ -124,7 +124,7 @@ export interface Sheet {
title: string;
/**
* The creator of the Sheet.
- * Format: user:{email}
+ * Format: users/{email}
*/
creator: string;
/** The create time of the sheet. */
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index e590a5e143..29333658f7 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -3399,12 +3399,12 @@ The instance's `name` field is used to identify the instance to update. Form
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| creator | [string](#string) | | The creator of the log entry. Format: user:{emailid} |
+| creator | [string](#string) | | The creator of the log entry. Format: users/{emailid} |
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The timestamp when the backup resource was created initally. |
| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The timestamp when the backup resource was updated. |
| action | [LogEntry.Action](#bytebase-v1-LogEntry-Action) | | |
| level | [LogEntry.Level](#bytebase-v1-LogEntry-Level) | | |
-| resource_name | [string](#string) | | The name of the resource associated with this log entry. For example, the resource user associated with log entry type of "ACTION_MEMBER_CREATE". Format: For ACTION_MEMBER_*: user:emailid For ACTION_ISSUE_*: issues/{issue} For ACTION_PIPELINE_*: pipelines/{pipeline} For ACTION_PROJECT_*: projects/{project} For ACTION_SQL_EDITOR_QUERY: workspaces/{workspace} OR projects/{project} |
+| resource_name | [string](#string) | | The name of the resource associated with this log entry. For example, the resource user associated with log entry type of "ACTION_MEMBER_CREATE". Format: For ACTION_MEMBER_*: users/{email} For ACTION_ISSUE_*: issues/{issue} For ACTION_PIPELINE_*: pipelines/{pipeline} For ACTION_PROJECT_*: projects/{project} For ACTION_SQL_EDITOR_QUERY: workspaces/{workspace} OR projects/{project} |
| json_payload | [google.protobuf.Struct](#google-protobuf-Struct) | | The payload of the log entry. |
@@ -4820,7 +4820,7 @@ When paginating, all other parameters provided to `ListReviews` must match the c
| approvers | [Review.Approver](#bytebase-v1-Review-Approver) | repeated | |
| approval_finding_done | [bool](#bool) | | If the value is `false`, it means that the backend is still finding matching approval templates. If `true`, approval_templates & approvers & approval_finding_error are available. |
| approval_finding_error | [string](#string) | | |
-| subscribers | [string](#string) | repeated | The subscribers. Format: user:[email protected] |
+| subscribers | [string](#string) | repeated | The subscribers. Format: users/[email protected] |
| creator | [string](#string) | | Format: users/[email protected] |
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
@@ -5902,7 +5902,7 @@ We support three types of SMTP encryption: NONE, STARTTLS, and SSL/TLS.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| parent | [string](#string) | | The parent resource of the sheet. Foramt: projects/{project} |
-| filter | [string](#string) | | To filter the search result. Format: only support the following spec for now: - `creator = user:{email}`, `creator != user:{email}` - `starred = true`, `starred = false`. Not support empty filter for now. |
+| filter | [string](#string) | | To filter the search result. Format: only support the following spec for now: - `creator = users/{email}`, `creator != users/{email}` - `starred = true`, `starred = false`. Not support empty filter for now. |
| page_size | [int32](#int32) | | Not used. The maximum number of sheets to return. The service may return fewer than this value. If unspecified, at most 50 sheets will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. |
| page_token | [string](#string) | | Not used. A page token, received from a previous `SearchSheets` call. Provide this to retrieve the subsequent page.
@@ -5940,7 +5940,7 @@ When paginating, all other parameters provided to `SearchSheets` must match the
| name | [string](#string) | | The name of the sheet resource, generated by the server. Canonical parent is project. Format: projects/{project}/sheets/{sheet} |
| database | [string](#string) | | The database resource name. Format: instances/{instance}/databases/{database} If the database parent doesn't exist, the database field is empty. |
| title | [string](#string) | | The title of the sheet. |
-| creator | [string](#string) | | The creator of the Sheet. Format: user:{email} |
+| creator | [string](#string) | | The creator of the Sheet. Format: users/{email} |
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The create time of the sheet. |
| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The last update time of the sheet. |
| content | [bytes](#bytes) | | The content of the sheet. By default, it will be cut off, if it doesn't match the `content_size`, you can set the `raw` to true in GetSheet request to retrieve the full content. |
diff --git a/proto/generated-go/v1/logging_service.pb.go b/proto/generated-go/v1/logging_service.pb.go
index 9dac6dd6be..a6c848eced 100644
--- a/proto/generated-go/v1/logging_service.pb.go
+++ b/proto/generated-go/v1/logging_service.pb.go
@@ -364,7 +364,7 @@ type LogEntry struct {
unknownFields protoimpl.UnknownFields
// The creator of the log entry.
- // Format: user:{emailid}
+ // Format: users/{emailid}
Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
// The timestamp when the backup resource was created initally.
CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
@@ -374,7 +374,7 @@ type LogEntry struct {
Level LogEntry_Level `protobuf:"varint,5,opt,name=level,proto3,enum=bytebase.v1.LogEntry_Level" json:"level,omitempty"`
// The name of the resource associated with this log entry. For example, the resource user associated with log entry type of "ACTION_MEMBER_CREATE".
// Format:
- // For ACTION_MEMBER_*: user:emailid
+ // For ACTION_MEMBER_*: users/{email}
// For ACTION_ISSUE_*: issues/{issue}
// For ACTION_PIPELINE_*: pipelines/{pipeline}
// For ACTION_PROJECT_*: projects/{project}
diff --git a/proto/generated-go/v1/review_service.pb.go b/proto/generated-go/v1/review_service.pb.go
index 2ddc45dbbf..b0dabddc37 100644
--- a/proto/generated-go/v1/review_service.pb.go
+++ b/proto/generated-go/v1/review_service.pb.go
@@ -710,7 +710,7 @@ type Review struct {
ApprovalFindingDone bool `protobuf:"varint,10,opt,name=approval_finding_done,json=approvalFindingDone,proto3" json:"approval_finding_done,omitempty"`
ApprovalFindingError string `protobuf:"bytes,11,opt,name=approval_finding_error,json=approvalFindingError,proto3" json:"approval_finding_error,omitempty"`
// The subscribers.
- // Format: user:[email protected]
+ // Format: users/[email protected]
Subscribers []string `protobuf:"bytes,12,rep,name=subscribers,proto3" json:"subscribers,omitempty"`
// Format: users/[email protected]
Creator string `protobuf:"bytes,13,opt,name=creator,proto3" json:"creator,omitempty"`
diff --git a/proto/generated-go/v1/sheet_service.pb.go b/proto/generated-go/v1/sheet_service.pb.go
index b8f495e035..9b4f678b51 100644
--- a/proto/generated-go/v1/sheet_service.pb.go
+++ b/proto/generated-go/v1/sheet_service.pb.go
@@ -430,7 +430,7 @@ type SearchSheetsRequest struct {
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
// To filter the search result.
// Format: only support the following spec for now:
- // - `creator = user:{email}`, `creator != user:{email}`
+ // - `creator = users/{email}`, `creator != users/{email}`
// - `starred = true`, `starred = false`.
// Not support empty filter for now.
Filter string `protobuf:"bytes,2,opt,name=filter,proto3" json:"filter,omitempty"`
@@ -631,7 +631,7 @@ type Sheet struct {
// The title of the sheet.
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
// The creator of the Sheet.
- // Format: user:{email}
+ // Format: users/{email}
Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"`
// The create time of the sheet.
CreateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
diff --git a/proto/v1/logging_service.proto b/proto/v1/logging_service.proto
index 9ab9f5b7c0..faf369ffc2 100644
--- a/proto/v1/logging_service.proto
+++ b/proto/v1/logging_service.proto
@@ -61,7 +61,7 @@ message ListLogsResponse {
message LogEntry {
// The creator of the log entry.
- // Format: user:{emailid}
+ // Format: users/{emailid}
string creator = 1 [(google.api.field_behavior) = REQUIRED];
// The timestamp when the backup resource was created initally.
@@ -143,7 +143,7 @@ message LogEntry {
// The name of the resource associated with this log entry. For example, the resource user associated with log entry type of "ACTION_MEMBER_CREATE".
// Format:
- // For ACTION_MEMBER_*: user:emailid
+ // For ACTION_MEMBER_*: users/{email}
// For ACTION_ISSUE_*: issues/{issue}
// For ACTION_PIPELINE_*: pipelines/{pipeline}
// For ACTION_PROJECT_*: projects/{project}
diff --git a/proto/v1/review_service.proto b/proto/v1/review_service.proto
index eb6fab8b63..f070296f2a 100644
--- a/proto/v1/review_service.proto
+++ b/proto/v1/review_service.proto
@@ -155,7 +155,7 @@ message Review {
string approval_finding_error = 11;
// The subscribers.
- // Format: user:[email protected]
+ // Format: users/[email protected]
repeated string subscribers = 12;
// Format: users/[email protected]
diff --git a/proto/v1/sheet_service.proto b/proto/v1/sheet_service.proto
index 39e3ec0b7c..8e689556a0 100644
--- a/proto/v1/sheet_service.proto
+++ b/proto/v1/sheet_service.proto
@@ -97,7 +97,7 @@ message SearchSheetsRequest {
// To filter the search result.
// Format: only support the following spec for now:
- // - `creator = user:{email}`, `creator != user:{email}`
+ // - `creator = users/{email}`, `creator != users/{email}`
// - `starred = true`, `starred = false`.
// Not support empty filter for now.
string filter = 2;
@@ -150,7 +150,7 @@ message Sheet {
string title = 3 [(google.api.field_behavior) = REQUIRED];
// The creator of the Sheet.
- // Format: user:{email}
+ // Format: users/{email}
string creator = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// The create time of the sheet.