Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(api): make update_mask decide what Update methods write (T15) (#21279)
Danny Xubc782608bdeb
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yamlindex ddb77b2363..363cce347a 100644--- a/backend/api/mcp/gen/openapi.yaml+++ b/backend/api/mcp/gen/openapi.yaml@@ -21363,17 +21363,13 @@ components:catalog:title: catalogdescription: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.$ref: '#/components/schemas/bytebase.v1.DatabaseCatalog'- allowMissing:- type: boolean- title: allow_missing- description: |-- If set to true, and the database catalog is not found, a new database catalog will be created.- In this situation, `update_mask` is ignored.title: UpdateDatabaseCatalogRequestadditionalProperties: falsedescription: Request message for updating a database catalog.diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex 8d2e809284..b7c8325d4a 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -10,6 +10,7 @@ import ("encoding/pem""log/slog""path/filepath"+ "slices""strings""time"@@ -1316,182 +1317,226 @@ func (s *InstanceService) UpdateDataSource(ctx context.Context, req *connect.Reqkrb.Keytab = nil}- for _, path := range req.Msg.UpdateMask.Paths {+ if err := applyDataSourceUpdateMask(dataSource, req.Msg.DataSource, req.Msg.UpdateMask.Paths); err != nil {+ return nil, err+ }++ // Run on the merged result, not inside the mask loop: whether the keytab+ // may be inherited depends on the destination the request ends at, and the+ // paths that move it can be applied after sasl_config.+ if err := retainStoredKeytabOnEmptyUpdate(dataSource, storedDataSource); err != nil {+ return nil, connect.NewError(connect.CodeInvalidArgument, err)+ }++ clearDataSourceAuthentication(dataSource)+ normalizeGCPDataSources(instance.Metadata.GetEngine(), []*storepb.DataSource{dataSource})+ if err := validateAndSanitizeDataSourceTLS(dataSource); err != nil {+ return nil, connect.NewError(connect.CodeInvalidArgument, err)+ }+ // Validate the merged result so untouched stored credentials keep passing:+ // the create-path SaaS checks never run for updates, which would otherwise+ // let an update strip an IAM credential down to the default chain.+ if err := s.validateIAMCredentialForSaaS(dataSource); err != nil {+ return nil, err+ }++ if err := s.checkInstanceDataSources(ctx, instance, metadata.GetDataSources()); err != nil {+ return nil, err+ }++ // Test connection.+ if req.Msg.ValidateOnly {+ if err := s.checkAndLogInstanceConnection(ctx, v1connect.InstanceServiceUpdateDataSourceProcedure, instance, dataSource); err != nil {+ return nil, err+ }+ result := s.convertToV1Instance(ctx, instanceWithMetadata(instance, metadata))+ return connect.NewResponse(result), nil+ }++ instance, err = s.store.UpdateInstance(ctx, &store.UpdateInstanceMessage{+ ResourceID: &instance.ResourceID,+ Workspace: instance.Workspace,+ Metadata: metadata,+ })+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, err)+ }+ result := s.convertToV1Instance(ctx, instance)+ return connect.NewResponse(result), nil+}++// applyDataSourceUpdateMask patches dataSource in place with the fields the+// mask names. It is the whole of what update_mask means for a data source, and+// it is pure so it can be exercised without a store.+func applyDataSourceUpdateMask(dataSource *storepb.DataSource, src *v1pb.DataSource, paths []string) error {+ // The authentication type the merged result will end at: the stored one+ // unless this request masks it. Resolved before the loop so a credential+ // path validates the same way whichever order the paths arrive in.+ effectiveAuthType := dataSource.GetAuthenticationType()+ if slices.Contains(paths, "authentication_type") {+ effectiveAuthType = convertV1AuthenticationType(src.AuthenticationType)+ }++ for _, path := range paths {switch path {case "username":- dataSource.Username = req.Msg.DataSource.Username+ dataSource.Username = src.Usernamecase "password":- dataSource.Password = req.Msg.DataSource.Password+ dataSource.Password = src.Passwordcase "ssl_ca":- dataSource.SslCa = req.Msg.DataSource.SslCa+ dataSource.SslCa = src.SslCacase "ssl_ca_path":- dataSource.SslCaPath = req.Msg.DataSource.SslCaPath+ dataSource.SslCaPath = src.SslCaPathcase "ssl_cert":- dataSource.SslCert = req.Msg.DataSource.SslCert+ dataSource.SslCert = src.SslCertcase "ssl_cert_path":- dataSource.SslCertPath = req.Msg.DataSource.SslCertPath+ dataSource.SslCertPath = src.SslCertPathcase "ssl_key":- dataSource.SslKey = req.Msg.DataSource.SslKey+ dataSource.SslKey = src.SslKeycase "ssl_key_path":- dataSource.SslKeyPath = req.Msg.DataSource.SslKeyPath+ dataSource.SslKeyPath = src.SslKeyPathcase "host":- dataSource.Host = req.Msg.DataSource.Host+ dataSource.Host = src.Hostcase "port":- dataSource.Port = req.Msg.DataSource.Port+ dataSource.Port = src.Portcase "database":- dataSource.Database = req.Msg.DataSource.Database+ dataSource.Database = src.Databasecase "srv":- dataSource.Srv = req.Msg.DataSource.Srv+ dataSource.Srv = src.Srvcase "authentication_database":- dataSource.AuthenticationDatabase = req.Msg.DataSource.AuthenticationDatabase+ dataSource.AuthenticationDatabase = src.AuthenticationDatabasecase "sid":- dataSource.Sid = req.Msg.DataSource.Sid+ dataSource.Sid = src.Sidcase "service_name":- dataSource.ServiceName = req.Msg.DataSource.ServiceName+ dataSource.ServiceName = src.ServiceNamecase "ssh_host":- dataSource.SshHost = req.Msg.DataSource.SshHost+ dataSource.SshHost = src.SshHostcase "ssh_port":- dataSource.SshPort = req.Msg.DataSource.SshPort+ dataSource.SshPort = src.SshPortcase "ssh_user":- dataSource.SshUser = req.Msg.DataSource.SshUser+ dataSource.SshUser = src.SshUsercase "ssh_password":- dataSource.SshPassword = req.Msg.DataSource.SshPassword+ dataSource.SshPassword = src.SshPasswordcase "ssh_private_key":- dataSource.SshPrivateKey = req.Msg.DataSource.SshPrivateKey+ dataSource.SshPrivateKey = src.SshPrivateKeycase "authentication_private_key":- dataSource.AuthenticationPrivateKey = req.Msg.DataSource.AuthenticationPrivateKey+ dataSource.AuthenticationPrivateKey = src.AuthenticationPrivateKeycase "authentication_private_key_passphrase":- dataSource.AuthenticationPrivateKeyPassphrase = req.Msg.DataSource.AuthenticationPrivateKeyPassphrase+ dataSource.AuthenticationPrivateKeyPassphrase = src.AuthenticationPrivateKeyPassphrasecase "external_secret":- externalSecret, err := convertV1DataSourceExternalSecret(req.Msg.DataSource.ExternalSecret)+ externalSecret, err := convertV1DataSourceExternalSecret(src.ExternalSecret)if err != nil {- return nil, err+ return err}dataSource.ExternalSecret = externalSecretcase "sasl_config":- dataSource.SaslConfig = convertV1DataSourceSaslConfig(req.Msg.DataSource.SaslConfig)+ dataSource.SaslConfig = convertV1DataSourceSaslConfig(src.SaslConfig)case "authentication_type":- dataSource.AuthenticationType = convertV1AuthenticationType(req.Msg.DataSource.AuthenticationType)+ dataSource.AuthenticationType = convertV1AuthenticationType(src.AuthenticationType)case "additional_addresses":- dataSource.AdditionalAddresses = convertAdditionalAddresses(req.Msg.DataSource.AdditionalAddresses)+ dataSource.AdditionalAddresses = convertAdditionalAddresses(src.AdditionalAddresses)case "replica_set":- dataSource.ReplicaSet = req.Msg.DataSource.ReplicaSet+ dataSource.ReplicaSet = src.ReplicaSetcase "direct_connection":- dataSource.DirectConnection = req.Msg.DataSource.DirectConnection+ dataSource.DirectConnection = src.DirectConnectioncase "region":- dataSource.Region = req.Msg.DataSource.Region+ dataSource.Region = src.Regioncase "warehouse_id":- dataSource.WarehouseId = req.Msg.DataSource.WarehouseId+ dataSource.WarehouseId = src.WarehouseIdcase "use_ssl":- dataSource.UseSsl = req.Msg.DataSource.UseSsl+ dataSource.UseSsl = src.UseSslcase "verify_tls_certificate":- dataSource.VerifyTlsCertificate = req.Msg.DataSource.VerifyTlsCertificate+ dataSource.VerifyTlsCertificate = src.VerifyTlsCertificatecase "redis_type":- dataSource.RedisType = convertV1RedisType(req.Msg.DataSource.RedisType)+ dataSource.RedisType = convertV1RedisType(src.RedisType)case "cloud_sql_ip_type":- dataSource.CloudSqlIpType = convertV1CloudSQLIPType(req.Msg.DataSource.CloudSqlIpType)+ dataSource.CloudSqlIpType = convertV1CloudSQLIPType(src.CloudSqlIpType)case "master_name":- dataSource.MasterName = req.Msg.DataSource.MasterName+ dataSource.MasterName = src.MasterNamecase "master_username":- dataSource.MasterUsername = req.Msg.DataSource.MasterUsername+ dataSource.MasterUsername = src.MasterUsernamecase "master_password":- dataSource.MasterPassword = req.Msg.DataSource.MasterPassword+ dataSource.MasterPassword = src.MasterPasswordcase "extra_connection_parameters":- dataSource.ExtraConnectionParameters = req.Msg.DataSource.ExtraConnectionParameters+ dataSource.ExtraConnectionParameters = src.ExtraConnectionParameterscase "project_id":- dataSource.ProjectId = req.Msg.DataSource.ProjectId+ dataSource.ProjectId = src.ProjectIdcase "instance_id":- dataSource.InstanceId = req.Msg.DataSource.InstanceId+ dataSource.InstanceId = src.InstanceIdcase "azure_credential", "aws_credential", "gcp_credential":- switch req.Msg.DataSource.AuthenticationType {- case v1pb.DataSource_AZURE_IAM:- if azureCredential := req.Msg.DataSource.GetAzureCredential(); azureCredential != nil {- dataSource.IamExtension = &storepb.DataSource_AzureCredential_{- AzureCredential: &storepb.DataSource_AzureCredential{- TenantId: azureCredential.TenantId,- ClientId: azureCredential.ClientId,- ClientSecret: azureCredential.ClientSecret,- },- }- dataSource.AuthenticationType = storepb.DataSource_AZURE_IAM- } else {- dataSource.IamExtension = nil- }- case v1pb.DataSource_AWS_RDS_IAM:- if awsCredential := req.Msg.DataSource.GetAwsCredential(); awsCredential != nil {- dataSource.IamExtension = &storepb.DataSource_AwsCredential{- AwsCredential: &storepb.DataSource_AWSCredential{- AccessKeyId: awsCredential.AccessKeyId,- SecretAccessKey: awsCredential.SecretAccessKey,- SessionToken: awsCredential.SessionToken,- RoleArn: awsCredential.RoleArn,- ExternalId: awsCredential.ExternalId,- },- }- dataSource.AuthenticationType = storepb.DataSource_AWS_RDS_IAM- } else {- dataSource.IamExtension = nil- }- case v1pb.DataSource_GOOGLE_CLOUD_SQL_IAM:- if gcpCredential := req.Msg.DataSource.GetGcpCredential(); gcpCredential != nil {- dataSource.IamExtension = &storepb.DataSource_GcpCredential{- GcpCredential: &storepb.DataSource_GCPCredential{- Content: gcpCredential.Content,- },- }- dataSource.AuthenticationType = storepb.DataSource_GOOGLE_CLOUD_SQL_IAM- } else {- dataSource.IamExtension = nil- }- default:+ // Dispatch on the mask path, never on the request's+ // authentication_type: an unset one used to fall through an empty+ // branch, so rotating a leaked credential returned 200 and wrote+ // nothing, and a mismatched one wrote a different credential than+ // the mask named while moving authentication_type itself.+ if want := credentialPathAuthType[path]; want != effectiveAuthType {+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf(+ `update_mask %q requires authentication_type %q, but the data source resolves to %q`,+ path, want, effectiveAuthType))}+ applyIAMCredential(dataSource, path, src)default:- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`unsupported update_mask "%s"`, path))+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`unsupported update_mask "%s"`, path))}}- // Run on the merged result, not inside the mask loop: whether the keytab- // may be inherited depends on the destination the request ends at, and the- // paths that move it can be applied after sasl_config.- if err := retainStoredKeytabOnEmptyUpdate(dataSource, storedDataSource); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, err)- }-- clearDataSourceAuthentication(dataSource)- normalizeGCPDataSources(instance.Metadata.GetEngine(), []*storepb.DataSource{dataSource})- if err := validateAndSanitizeDataSourceTLS(dataSource); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, err)- }- // Validate the merged result so untouched stored credentials keep passing:- // the create-path SaaS checks never run for updates, which would otherwise- // let an update strip an IAM credential down to the default chain.- if err := s.validateIAMCredentialForSaaS(dataSource); err != nil {- return nil, err- }+ return nil+}- if err := s.checkInstanceDataSources(ctx, instance, metadata.GetDataSources()); err != nil {- return nil, err- }+// credentialPathAuthType maps each IAM credential mask path to the single+// authentication type that owns it.+var credentialPathAuthType = map[string]storepb.DataSource_AuthenticationType{+ "azure_credential": storepb.DataSource_AZURE_IAM,+ "aws_credential": storepb.DataSource_AWS_RDS_IAM,+ "gcp_credential": storepb.DataSource_GOOGLE_CLOUD_SQL_IAM,+}- // Test connection.- if req.Msg.ValidateOnly {- if err := s.checkAndLogInstanceConnection(ctx, v1connect.InstanceServiceUpdateDataSourceProcedure, instance, dataSource); err != nil {- return nil, err+// applyIAMCredential writes the one credential named by path. A path naming an+// absent credential clears the extension, which is what a mask that names the+// field with no value means.+func applyIAMCredential(dataSource *storepb.DataSource, path string, src *v1pb.DataSource) {+ switch path {+ case "azure_credential":+ azureCredential := src.GetAzureCredential()+ if azureCredential == nil {+ dataSource.IamExtension = nil+ return+ }+ dataSource.IamExtension = &storepb.DataSource_AzureCredential_{+ AzureCredential: &storepb.DataSource_AzureCredential{+ TenantId: azureCredential.TenantId,+ ClientId: azureCredential.ClientId,+ ClientSecret: azureCredential.ClientSecret,+ },}- result := s.convertToV1Instance(ctx, instanceWithMetadata(instance, metadata))- return connect.NewResponse(result), nil- }-- instance, err = s.store.UpdateInstance(ctx, &store.UpdateInstanceMessage{- ResourceID: &instance.ResourceID,- Workspace: instance.Workspace,- Metadata: metadata,- })- if err != nil {- return nil, connect.NewError(connect.CodeInternal, err)+ case "aws_credential":+ awsCredential := src.GetAwsCredential()+ if awsCredential == nil {+ dataSource.IamExtension = nil+ return+ }+ dataSource.IamExtension = &storepb.DataSource_AwsCredential{+ AwsCredential: &storepb.DataSource_AWSCredential{+ AccessKeyId: awsCredential.AccessKeyId,+ SecretAccessKey: awsCredential.SecretAccessKey,+ SessionToken: awsCredential.SessionToken,+ RoleArn: awsCredential.RoleArn,+ ExternalId: awsCredential.ExternalId,+ },+ }+ case "gcp_credential":+ gcpCredential := src.GetGcpCredential()+ if gcpCredential == nil {+ dataSource.IamExtension = nil+ return+ }+ dataSource.IamExtension = &storepb.DataSource_GcpCredential{+ GcpCredential: &storepb.DataSource_GCPCredential{+ Content: gcpCredential.Content,+ },+ }+ default:}- result := s.convertToV1Instance(ctx, instance)- return connect.NewResponse(result), nil}// RemoveDataSource removes a data source to an instance.diff --git a/backend/api/v1/instance_service_test.go b/backend/api/v1/instance_service_test.goindex 00a2c18a21..270c4c6703 100644--- a/backend/api/v1/instance_service_test.go+++ b/backend/api/v1/instance_service_test.go@@ -526,3 +526,74 @@ func TestValidateExternalSecretForSaaS(t *testing.T) {})}}++// TestApplyDataSourceUpdateMaskCredentials covers the T15 headline: the mask+// path decides which IAM credential is written. The branch used to dispatch on+// the request's authentication_type, which an AIP-134 client leaves unset when+// it masks only the credential — so rotating a leaked key wrote nothing and+// returned 200.+func TestApplyDataSourceUpdateMaskCredentials(t *testing.T) {+ gcpStored := func() *storepb.DataSource {+ return &storepb.DataSource{+ Id: "admin",+ AuthenticationType: storepb.DataSource_GOOGLE_CLOUD_SQL_IAM,+ IamExtension: &storepb.DataSource_GcpCredential{+ GcpCredential: &storepb.DataSource_GCPCredential{Content: "leaked"},+ },+ }+ }++ t.Run("rotation without authentication_type in the body", func(t *testing.T) {+ dataSource := gcpStored()+ err := applyDataSourceUpdateMask(dataSource, &v1pb.DataSource{+ IamExtension: &v1pb.DataSource_GcpCredential{+ GcpCredential: &v1pb.DataSource_GCPCredential{Content: "rotated"},+ },+ }, []string{"gcp_credential"})+ require.NoError(t, err)+ require.Equal(t, "rotated", dataSource.GetGcpCredential().GetContent())+ })++ t.Run("credential path disagreeing with the stored type", func(t *testing.T) {+ dataSource := gcpStored()+ err := applyDataSourceUpdateMask(dataSource, &v1pb.DataSource{+ AuthenticationType: v1pb.DataSource_AWS_RDS_IAM,+ IamExtension: &v1pb.DataSource_AwsCredential{+ AwsCredential: &v1pb.DataSource_AWSCredential{AccessKeyId: "AKIA"},+ },+ }, []string{"aws_credential"})+ require.Error(t, err)+ require.Equal(t, connect.CodeInvalidArgument, connect.CodeOf(err))+ require.Equal(t, "leaked", dataSource.GetGcpCredential().GetContent())+ require.Equal(t, storepb.DataSource_GOOGLE_CLOUD_SQL_IAM, dataSource.GetAuthenticationType())+ })++ t.Run("switching type and credential together, either path order", func(t *testing.T) {+ for _, paths := range [][]string{+ {"authentication_type", "aws_credential"},+ {"aws_credential", "authentication_type"},+ } {+ dataSource := gcpStored()+ err := applyDataSourceUpdateMask(dataSource, &v1pb.DataSource{+ AuthenticationType: v1pb.DataSource_AWS_RDS_IAM,+ IamExtension: &v1pb.DataSource_AwsCredential{+ AwsCredential: &v1pb.DataSource_AWSCredential{AccessKeyId: "AKIA"},+ },+ }, paths)+ require.NoError(t, err, paths)+ require.Equal(t, "AKIA", dataSource.GetAwsCredential().GetAccessKeyId())+ }+ })++ t.Run("a masked credential the body omits is cleared", func(t *testing.T) {+ dataSource := gcpStored()+ require.NoError(t, applyDataSourceUpdateMask(dataSource, &v1pb.DataSource{}, []string{"gcp_credential"}))+ require.Nil(t, dataSource.GetIamExtension())+ })++ t.Run("unknown path", func(t *testing.T) {+ err := applyDataSourceUpdateMask(gcpStored(), &v1pb.DataSource{}, []string{"nope"})+ require.Error(t, err)+ require.Equal(t, connect.CodeInvalidArgument, connect.CodeOf(err))+ })+}diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex 19cc29e6b9..92994456d1 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -945,6 +945,10 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1pcase "draft":// Submission is committed below through the review workflow.default:+ // status moves through BatchUpdateIssuesStatus and approvals through+ // ApproveIssue/RejectIssue, so those paths are not silently dropped+ // here — they are not this method's to apply.+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`unsupported update_mask "%s"`, path))}}diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.goindex 1c2653b107..9b907cefc3 100644--- a/backend/api/v1/setting_service.go+++ b/backend/api/v1/setting_service.go@@ -4,6 +4,7 @@ import ("context""log/slog""regexp"+ "slices""strings""time"@@ -263,84 +264,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Req}storeSettingValue = payloadcase storepb.SettingName_APP_IM:- payload, err := convertAppIMSetting(request.Msg.Setting.Value.GetAppIm())- if err != nil {- return nil, err- }-- // Helper function to find or create an IM setting entry by type- findIMSetting := func(imType storepb.WebhookType) *storepb.AppIMSetting_IMSetting {- for _, s := range payload.Settings {- if s.Type == imType {- return s- }- }- return nil- }-- for _, path := range request.Msg.GetUpdateMask().GetPaths() {- switch path {- case "value.app_im.slack":- slackSetting := findIMSetting(storepb.WebhookType_SLACK)- if slackSetting == nil || slackSetting.GetSlack() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found slack setting"))- }- if err := slack.ValidateToken(ctx, slackSetting.GetSlack().GetToken()); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- case "value.app_im.feishu":- feishuSetting := findIMSetting(storepb.WebhookType_FEISHU)- if feishuSetting == nil || feishuSetting.GetFeishu() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found feishu setting"))- }- if err := feishu.Validate(ctx, feishuSetting.GetFeishu().GetAppId(), feishuSetting.GetFeishu().GetAppSecret(), user.Email); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- case "value.app_im.wecom":- wecomSetting := findIMSetting(storepb.WebhookType_WECOM)- if wecomSetting == nil || wecomSetting.GetWecom() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found wecom setting"))- }- if err := wecom.Validate(ctx, wecomSetting.GetWecom().GetCorpId(), wecomSetting.GetWecom().GetAgentId(), wecomSetting.GetWecom().GetSecret()); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- case "value.app_im.lark":- larkSetting := findIMSetting(storepb.WebhookType_LARK)- if larkSetting == nil || larkSetting.GetLark() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found lark setting"))- }- if err := lark.Validate(ctx, larkSetting.GetLark().GetAppId(), larkSetting.GetLark().GetAppSecret(), user.Email); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- case "value.app_im.dingtalk":- dingtalkSetting := findIMSetting(storepb.WebhookType_DINGTALK)- if dingtalkSetting == nil || dingtalkSetting.GetDingtalk() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found dingtalk setting"))- }- if err := dingtalk.Validate(ctx, dingtalkSetting.GetDingtalk().GetClientId(), dingtalkSetting.GetDingtalk().GetClientSecret(), dingtalkSetting.GetDingtalk().GetRobotCode(), user.Phone); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- case "value.app_im_setting_value.teams":- teamsSetting := findIMSetting(storepb.WebhookType_TEAMS)- if teamsSetting == nil || teamsSetting.GetTeams() == nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("cannot found teams setting"))- }- if err := teams.Validate(ctx, teamsSetting.GetTeams().GetTenantId(), teamsSetting.GetTeams().GetClientId(), teamsSetting.GetTeams().GetClientSecret(), user.Email); err != nil {- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))- }-- default:- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid update mask path %v", path))- }- }-- storeSettingValue = payload-+ return s.updateAppIMSetting(ctx, request, workspaceID, user)case storepb.SettingName_DATA_CLASSIFICATION:if err := s.licenseService.IsFeatureEnabled(ctx, workspaceID, v1pb.PlanFeature_FEATURE_DATA_CLASSIFICATION); err != nil {return nil, connect.NewError(connect.CodePermissionDenied, err)@@ -586,6 +510,199 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Reqreturn connect.NewResponse(settingMessage), nil}+// appIMSettingMaskPath maps each accepted APP_IM mask path to the provider it+// addresses. The paths do not name real proto fields — AppIMSetting holds one+// repeated `settings`, and AIP-161 does not let a mask address a repeated+// element — so they are matched as a fixed vocabulary rather than traversed.+var appIMSettingMaskPath = map[string]storepb.WebhookType{+ "value.app_im.slack": storepb.WebhookType_SLACK,+ "value.app_im.feishu": storepb.WebhookType_FEISHU,+ "value.app_im.wecom": storepb.WebhookType_WECOM,+ "value.app_im.lark": storepb.WebhookType_LARK,+ "value.app_im.dingtalk": storepb.WebhookType_DINGTALK,+ "value.app_im_setting_value.teams": storepb.WebhookType_TEAMS,+}++// updateAppIMSetting handles the APP_IM branch of UpdateSetting through the+// store's row-locking read-modify-write primitive: the merge runs inside the+// transaction against the value of the locked row, so two admins configuring+// different providers at once cannot each merge onto the same stale snapshot+// and have the later write restore the other's provider from it. The row is+// seeded at workspace creation, so the primitive always finds it.+func (s *SettingService) updateAppIMSetting(ctx context.Context, request *connect.Request[v1pb.UpdateSettingRequest], workspaceID string, user *store.UserMessage) (*connect.Response[v1pb.Setting], error) {+ if request.Msg.UpdateMask == nil {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("update mask is required"))+ }+ payload, err := convertAppIMSetting(request.Msg.Setting.Value.GetAppIm())+ if err != nil {+ return nil, err+ }+ if err := preflightAppIMPaths(ctx, payload, request.Msg.UpdateMask.Paths, user); err != nil {+ return nil, err+ }++ var lockedBefore *storepb.AppIMSetting+ apply := func(current proto.Message) (proto.Message, error) {+ stored, ok := current.(*storepb.AppIMSetting)+ if !ok {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("invalid setting value type for %s", storepb.SettingName_APP_IM))+ }+ // The audit before-image is the row this merge actually ran against,+ // not the possibly stale pre-lock snapshot captured by UpdateSetting.+ lockedBefore = proto.CloneOf(stored)+ return mergeAppIMSetting(stored, payload, request.Msg.UpdateMask.Paths)+ }++ if request.Msg.ValidateOnly {+ fresh, err := s.store.GetSettingUncached(ctx, workspaceID, storepb.SettingName_APP_IM)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find setting %s with error: %v", storepb.SettingName_APP_IM, err))+ }+ if fresh == nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("cannot find setting %v", storepb.SettingName_APP_IM))+ }+ merged, err := apply(fresh.Value)+ if err != nil {+ return nil, err+ }+ // Return the merged value, not the request: the request carries only+ // the masked providers, so echoing it would show every provider this+ // update preserves as gone.+ return newAppIMSettingResponse(workspaceID, merged)+ }++ setting, err := s.store.UpdateSettingAtomic(ctx, workspaceID, storepb.SettingName_APP_IM, apply, nil)+ if err != nil {+ var connectErr *connect.Error+ if errors.As(err, &connectErr) {+ return nil, err+ }+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to set setting: %v", err))+ }++ // Re-capture the audit before-image from the locked row the merge ran+ // against, overwriting UpdateSetting's earlier pre-lock snapshot.+ if setServiceData, ok := common.GetSetServiceDataFromContext(ctx); ok && lockedBefore != nil {+ v1pbSetting, err := convertToSettingMessage(&store.SettingMessage{+ Name: storepb.SettingName_APP_IM,+ Workspace: workspaceID,+ Value: lockedBefore,+ })+ if err != nil {+ slog.Warn("audit: failed to convert to v1.Setting", log.BBError(err))+ }+ p, err := anypb.New(v1pbSetting)+ if err != nil {+ slog.Warn("audit: failed to convert to anypb.Any", log.BBError(err))+ }+ setServiceData(p)+ }++ settingMessage, err := convertToSettingMessage(setting)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))+ }+ return connect.NewResponse(settingMessage), nil+}++func newAppIMSettingResponse(workspaceID string, value proto.Message) (*connect.Response[v1pb.Setting], error) {+ settingMessage, err := convertToSettingMessage(&store.SettingMessage{+ Name: storepb.SettingName_APP_IM,+ Workspace: workspaceID,+ Value: value,+ })+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))+ }+ return connect.NewResponse(settingMessage), nil+}++// preflightAppIMPaths validates the credentials of every provider the mask+// names and the payload carries. It runs BEFORE the row-locking transaction:+// each check is a round trip to the provider's own API, and holding the+// setting row lock across one would let a slow vendor block every other write+// to this row. None of it depends on the locked row.+func preflightAppIMPaths(ctx context.Context, payload *storepb.AppIMSetting, paths []string, user *store.UserMessage) error {+ for _, path := range paths {+ imType, ok := appIMSettingMaskPath[path]+ if !ok {+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid update mask path %v", path))+ }+ incoming := findIMSetting(payload.GetSettings(), imType)+ if incoming == nil || incoming.GetPayload() == nil {+ // A masked provider the payload omits is a removal.+ continue+ }+ if err := validateIMSetting(ctx, incoming, user); err != nil {+ return err+ }+ }+ return nil+}++// mergeAppIMSetting splices only the masked providers of payload into stored.+// Assigning the request wholesale used to drop every provider it left out, so+// saving Slack wiped the stored Feishu, WeCom, Lark, DingTalk and Teams+// secrets. A masked provider the payload omits is removed, which is how one is+// deleted. stored is not modified.+func mergeAppIMSetting(stored, payload *storepb.AppIMSetting, paths []string) (*storepb.AppIMSetting, error) {+ merged := proto.CloneOf(stored)+ for _, path := range paths {+ imType, ok := appIMSettingMaskPath[path]+ if !ok {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid update mask path %v", path))+ }+ incoming := findIMSetting(payload.GetSettings(), imType)+ if incoming == nil || incoming.GetPayload() == nil {+ merged.Settings = slices.DeleteFunc(merged.Settings, func(s *storepb.AppIMSetting_IMSetting) bool {+ return s.GetType() == imType+ })+ continue+ }+ if existing := findIMSetting(merged.GetSettings(), imType); existing != nil {+ proto.Reset(existing)+ proto.Merge(existing, incoming)+ } else {+ merged.Settings = append(merged.Settings, incoming)+ }+ }+ return merged, nil+}++func findIMSetting(settings []*storepb.AppIMSetting_IMSetting, imType storepb.WebhookType) *storepb.AppIMSetting_IMSetting {+ for _, setting := range settings {+ if setting.GetType() == imType {+ return setting+ }+ }+ return nil+}++// validateIMSetting checks the provider's credentials against its own API.+func validateIMSetting(ctx context.Context, setting *storepb.AppIMSetting_IMSetting, user *store.UserMessage) error {+ var err error+ switch setting.GetType() {+ case storepb.WebhookType_SLACK:+ err = slack.ValidateToken(ctx, setting.GetSlack().GetToken())+ case storepb.WebhookType_FEISHU:+ err = feishu.Validate(ctx, setting.GetFeishu().GetAppId(), setting.GetFeishu().GetAppSecret(), user.Email)+ case storepb.WebhookType_WECOM:+ err = wecom.Validate(ctx, setting.GetWecom().GetCorpId(), setting.GetWecom().GetAgentId(), setting.GetWecom().GetSecret())+ case storepb.WebhookType_LARK:+ err = lark.Validate(ctx, setting.GetLark().GetAppId(), setting.GetLark().GetAppSecret(), user.Email)+ case storepb.WebhookType_DINGTALK:+ err = dingtalk.Validate(ctx, setting.GetDingtalk().GetClientId(), setting.GetDingtalk().GetClientSecret(), setting.GetDingtalk().GetRobotCode(), user.Phone)+ case storepb.WebhookType_TEAMS:+ err = teams.Validate(ctx, setting.GetTeams().GetTenantId(), setting.GetTeams().GetClientId(), setting.GetTeams().GetClientSecret(), user.Email)+ default:+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupported IM type %v", setting.GetType()))+ }+ if err != nil {+ return connect.NewError(connect.CodeInvalidArgument, errors.Wrapf(err, "validation failed"))+ }+ return nil+}+// updateWorkspaceProfileSetting handles the WORKSPACE_PROFILE branch of// UpdateSetting through the store's row-locking read-modify-write primitive:// the update-mask merge and its validations run inside the transaction againstdiff --git a/backend/api/v1/setting_service_test.go b/backend/api/v1/setting_service_test.goindex fc703a7ddf..74da75976e 100644--- a/backend/api/v1/setting_service_test.go+++ b/backend/api/v1/setting_service_test.go@@ -282,3 +282,61 @@ func TestPreflightWorkspaceProfileSaaSRestrictedPaths(t *testing.T) {require.NoError(t, err, path)}}++// TestMergeAppIMSetting covers the second T15 site: saving one provider used to+// assign the request wholesale over the stored setting, erasing every provider+// it left out.+func TestMergeAppIMSetting(t *testing.T) {+ stored := func() *storepb.AppIMSetting {+ return &storepb.AppIMSetting{Settings: []*storepb.AppIMSetting_IMSetting{+ {+ Type: storepb.WebhookType_SLACK,+ Payload: &storepb.AppIMSetting_IMSetting_Slack{Slack: &storepb.AppIMSetting_Slack{Token: "slack-token"}},+ },+ {+ Type: storepb.WebhookType_FEISHU,+ Payload: &storepb.AppIMSetting_IMSetting_Feishu{Feishu: &storepb.AppIMSetting_Feishu{AppSecret: "feishu-secret"}},+ },+ }}+ }+ feishuSecret := func(s *storepb.AppIMSetting) string {+ return findIMSetting(s.GetSettings(), storepb.WebhookType_FEISHU).GetFeishu().GetAppSecret()+ }++ t.Run("saving one provider leaves the others alone", func(t *testing.T) {+ payload := &storepb.AppIMSetting{Settings: []*storepb.AppIMSetting_IMSetting{{+ Type: storepb.WebhookType_SLACK,+ Payload: &storepb.AppIMSetting_IMSetting_Slack{Slack: &storepb.AppIMSetting_Slack{Token: "new-token"}},+ }}}+ merged, err := mergeAppIMSetting(stored(), payload, []string{"value.app_im.slack"})+ require.NoError(t, err)+ require.Equal(t, "new-token", findIMSetting(merged.GetSettings(), storepb.WebhookType_SLACK).GetSlack().GetToken())+ require.Equal(t, "feishu-secret", feishuSecret(merged))+ })++ t.Run("a masked provider the payload omits is removed", func(t *testing.T) {+ merged, err := mergeAppIMSetting(stored(), &storepb.AppIMSetting{}, []string{"value.app_im.slack"})+ require.NoError(t, err)+ require.Nil(t, findIMSetting(merged.GetSettings(), storepb.WebhookType_SLACK))+ require.Equal(t, "feishu-secret", feishuSecret(merged))+ })++ t.Run("adding a provider that is not configured yet", func(t *testing.T) {+ payload := &storepb.AppIMSetting{Settings: []*storepb.AppIMSetting_IMSetting{{+ Type: storepb.WebhookType_TEAMS,+ Payload: &storepb.AppIMSetting_IMSetting_Teams{Teams: &storepb.AppIMSetting_Teams{TenantId: "tenant"}},+ }}}+ merged, err := mergeAppIMSetting(stored(), payload, []string{"value.app_im_setting_value.teams"})+ require.NoError(t, err)+ require.Equal(t, "tenant", findIMSetting(merged.GetSettings(), storepb.WebhookType_TEAMS).GetTeams().GetTenantId())+ require.Len(t, merged.GetSettings(), 3)+ })++ t.Run("unknown path, and the stored value is never mutated", func(t *testing.T) {+ before := stored()+ _, err := mergeAppIMSetting(before, &storepb.AppIMSetting{}, []string{"value.app_im.mattermost"})+ require.Error(t, err)+ require.Equal(t, connect.CodeInvalidArgument, connect.CodeOf(err))+ require.Equal(t, "feishu-secret", feishuSecret(before))+ })+}diff --git a/backend/generated-go/v1/database_catalog_service.pb.go b/backend/generated-go/v1/database_catalog_service.pb.goindex ce48139d48..d526fe9f70 100644--- a/backend/generated-go/v1/database_catalog_service.pb.go+++ b/backend/generated-go/v1/database_catalog_service.pb.go@@ -137,14 +137,13 @@ func (x *GetDatabaseCatalogRequest) GetName() string {// Request message for updating a database catalog.type UpdateDatabaseCatalogRequest struct {state protoimpl.MessageState `protogen:"open.v1"`- // The database catalog to update.- //- // The catalog's `name` field is used to identify the database catalog to update.+ // The database catalog to update, identified by its `name` field.// Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog- Catalog *DatabaseCatalog `protobuf:"bytes,1,opt,name=catalog,proto3" json:"catalog,omitempty"`- // If set to true, and the database catalog is not found, a new database catalog will be created.- // In this situation, `update_mask` is ignored.- AllowMissing bool `protobuf:"varint,2,opt,name=allow_missing,json=allowMissing,proto3" json:"allow_missing,omitempty"`+ //+ // Replaces the whole catalog: send the complete value, since anything omitted+ // is erased. There is no `update_mask` because `schemas` is a repeated field,+ // and AIP-161 forbids addressing one element of one.+ Catalog *DatabaseCatalog `protobuf:"bytes,1,opt,name=catalog,proto3" json:"catalog,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCache}@@ -186,13 +185,6 @@ func (x *UpdateDatabaseCatalogRequest) GetCatalog() *DatabaseCatalog {return nil}-func (x *UpdateDatabaseCatalogRequest) GetAllowMissing() bool {- if x != nil {- return x.AllowMissing- }- return false-}-// Catalog metadata for a database including schemas, tables, and columns.type DatabaseCatalog struct {state protoimpl.MessageState `protogen:"open.v1"`@@ -737,10 +729,9 @@ const file_v1_database_catalog_service_proto_rawDesc = "" +"!v1/database_catalog_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x13v1/annotation.proto\"U\n" +"\x19GetDatabaseCatalogRequest\x128\n" +"\x04name\x18\x01 \x01(\tB$\xe0A\x02\xfaA\x1e\n" +- "\x1cbytebase.com/DatabaseCatalogR\x04name\"\x80\x01\n" ++ "\x1cbytebase.com/DatabaseCatalogR\x04name\"p\n" +"\x1cUpdateDatabaseCatalogRequest\x12;\n" +- "\acatalog\x18\x01 \x01(\v2\x1c.bytebase.v1.DatabaseCatalogB\x03\xe0A\x02R\acatalog\x12#\n" +- "\rallow_missing\x18\x02 \x01(\bR\fallowMissing\"\xf9\x01\n" ++ "\acatalog\x18\x01 \x01(\v2\x1c.bytebase.v1.DatabaseCatalogB\x03\xe0A\x02R\acatalogJ\x04\b\x02\x10\x03R\rallow_missing\"\xf9\x01\n" +"\x0fDatabaseCatalog\x12\x12\n" +"\x04name\x18\x01 \x01(\tR\x04name\x124\n" +"\aschemas\x18\x02 \x03(\v2\x1a.bytebase.v1.SchemaCatalogR\aschemas:\x9b\x01\xeaA\x97\x01\n" +@@ -793,10 +784,10 @@ const file_v1_database_catalog_service_proto_rawDesc = "" +"\n" +"\x06OBJECT\x10\x04\x12\t\n" +"\x05ARRAY\x10\x05B\x06\n" +- "\x04kind2\xc5\x04\n" ++ "\x04kind2\xb9\x04\n" +"\x16DatabaseCatalogService\x12\xf2\x01\n" +- "\x12GetDatabaseCatalog\x12&.bytebase.v1.GetDatabaseCatalogRequest\x1a\x1c.bytebase.v1.DatabaseCatalog\"\x95\x01\xdaA\x04name\x8a\xea0\x17bb.databaseCatalogs.get\x90\xea0\x01\xa0\xea0\x01\x82\xd3\xe4\x93\x02eZ7\x125/v1/{name=projects/*/instances/*/databases/*/catalog}\x12*/v1/{name=instances/*/databases/*/catalog}\x12\xb5\x02\n" +- "\x15UpdateDatabaseCatalog\x12).bytebase.v1.UpdateDatabaseCatalogRequest\x1a\x1c.bytebase.v1.DatabaseCatalog\"\xd2\x01\xdaA\x13catalog,update_mask\x8a\xea0\x1abb.databaseCatalogs.update\x90\xea0\x01\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02\x87\x01:\acatalogZH:\acatalog2=/v1/{catalog.name=projects/*/instances/*/databases/*/catalog}22/v1/{catalog.name=instances/*/databases/*/catalog}B\xb1\x01\n" ++ "\x12GetDatabaseCatalog\x12&.bytebase.v1.GetDatabaseCatalogRequest\x1a\x1c.bytebase.v1.DatabaseCatalog\"\x95\x01\xdaA\x04name\x8a\xea0\x17bb.databaseCatalogs.get\x90\xea0\x01\xa0\xea0\x01\x82\xd3\xe4\x93\x02eZ7\x125/v1/{name=projects/*/instances/*/databases/*/catalog}\x12*/v1/{name=instances/*/databases/*/catalog}\x12\xa9\x02\n" ++ "\x15UpdateDatabaseCatalog\x12).bytebase.v1.UpdateDatabaseCatalogRequest\x1a\x1c.bytebase.v1.DatabaseCatalog\"\xc6\x01\xdaA\acatalog\x8a\xea0\x1abb.databaseCatalogs.update\x90\xea0\x01\x98\xea0\x01\xa0\xea0\x04\xa8\xea0\t\x82\xd3\xe4\x93\x02\x87\x01:\acatalogZH:\acatalog2=/v1/{catalog.name=projects/*/instances/*/databases/*/catalog}22/v1/{catalog.name=instances/*/databases/*/catalog}B\xb1\x01\n" +"\x0fcom.bytebase.v1B\x1bDatabaseCatalogServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"var (diff --git a/backend/generated-go/v1/database_catalog_service.pb.gw.go b/backend/generated-go/v1/database_catalog_service.pb.gw.goindex 8a3d7d3115..4238afb4d2 100644--- a/backend/generated-go/v1/database_catalog_service.pb.gw.go+++ b/backend/generated-go/v1/database_catalog_service.pb.gw.go@@ -113,8 +113,6 @@ func local_request_DatabaseCatalogService_GetDatabaseCatalog_1(ctx context.Contereturn msg, metadata, err}-var filter_DatabaseCatalogService_UpdateDatabaseCatalog_0 = &utilities.DoubleArray{Encoding: map[string]int{"catalog": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}-func request_DatabaseCatalogService_UpdateDatabaseCatalog_0(ctx context.Context, marshaler runtime.Marshaler, client DatabaseCatalogServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {var (protoReq UpdateDatabaseCatalogRequest@@ -132,12 +130,6 @@ func request_DatabaseCatalogService_UpdateDatabaseCatalog_0(ctx context.Context,if err != nil {return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "catalog.name", err)}- if err := req.ParseForm(); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatabaseCatalogService_UpdateDatabaseCatalog_0); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }if req.Body != nil {_, _ = io.Copy(io.Discard, req.Body)}@@ -162,18 +154,10 @@ func local_request_DatabaseCatalogService_UpdateDatabaseCatalog_0(ctx context.Coif err != nil {return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "catalog.name", err)}- if err := req.ParseForm(); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatabaseCatalogService_UpdateDatabaseCatalog_0); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }msg, err := server.UpdateDatabaseCatalog(ctx, &protoReq)return msg, metadata, err}-var filter_DatabaseCatalogService_UpdateDatabaseCatalog_1 = &utilities.DoubleArray{Encoding: map[string]int{"catalog": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}-func request_DatabaseCatalogService_UpdateDatabaseCatalog_1(ctx context.Context, marshaler runtime.Marshaler, client DatabaseCatalogServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {var (protoReq UpdateDatabaseCatalogRequest@@ -191,12 +175,6 @@ func request_DatabaseCatalogService_UpdateDatabaseCatalog_1(ctx context.Context,if err != nil {return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "catalog.name", err)}- if err := req.ParseForm(); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatabaseCatalogService_UpdateDatabaseCatalog_1); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }if req.Body != nil {_, _ = io.Copy(io.Discard, req.Body)}@@ -221,12 +199,6 @@ func local_request_DatabaseCatalogService_UpdateDatabaseCatalog_1(ctx context.Coif err != nil {return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "catalog.name", err)}- if err := req.ParseForm(); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatabaseCatalogService_UpdateDatabaseCatalog_1); err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }msg, err := server.UpdateDatabaseCatalog(ctx, &protoReq)return msg, metadata, err}diff --git a/backend/generated-go/v1/database_catalog_service_equal.pb.go b/backend/generated-go/v1/database_catalog_service_equal.pb.goindex 12a949327d..661327e6df 100644--- a/backend/generated-go/v1/database_catalog_service_equal.pb.go+++ b/backend/generated-go/v1/database_catalog_service_equal.pb.go@@ -26,9 +26,6 @@ func (x *UpdateDatabaseCatalogRequest) Equal(y *UpdateDatabaseCatalogRequest) boif !x.Catalog.Equal(y.Catalog) {return false}- if x.AllowMissing != y.AllowMissing {- return false- }return true}diff --git a/docs/design/v1-api-audit-2026-08.md b/docs/design/v1-api-audit-2026-08.mdindex b4e4bfb184..c147962ac3 100644--- a/docs/design/v1-api-audit-2026-08.md+++ b/docs/design/v1-api-audit-2026-08.md@@ -10,7 +10,6 @@ noted. Fixed findings are removed and listed at the end.| | Problem | Severity ||---|---|---|-| T15 | Rotating a leaked cloud credential can silently do nothing | HIGH || T13 | "Waiting for my approval" can show an empty page with a live Load More | HIGH || T12 | Anonymous callers can enumerate emails, relay mail, and read your LDAP config | MED || T16 | Four `BatchGet` RPCs behave four different ways when an item is missing | MED |@@ -58,28 +57,6 @@ enforced. It's decorative, and it reads as protection. `acl.go:251-253`, `group_## The API says OK and does nothing-### T15 · `update_mask` is ignored in four places — HIGH--The worst one: **rotating a leaked cloud credential can silently no-op.** `UpdateDataSource` decides-what to write based on the `authentication_type` in the request rather than the mask or the stored-value, so a request carrying only a new GCP credential falls through an empty branch and writes-nothing. You get HTTP 200 and the compromised key stays live. `instance_service.go:1405-1447`--The other three lose data rather than fail to save it:--- **`UpdateSetting` replaces whole settings.** Updating your Slack config wipes stored Feishu, WeCom,- Lark, DingTalk and Teams secrets — and it *validates* the mask path first, then ignores it. For- environments the replace cascades into every instance and database. `setting_service.go:329-391`,- `:505-525`-- **`UpdateDatabaseCatalog` never reads a mask at all** and replaces the whole config column, wiping- other schemas' classification and masking. Its proto comment refers to an `update_mask` field that- doesn't exist. `database_catalog_service.go:96-139`-- **`UpdateIssue` implements four fields** and silently drops the rest, so `update_mask=["status"]`- returns 200 and does nothing. `issue_service.go:922-948`--Underneath: some Update RPCs reject unknown mask paths, others ignore them, in four different error-wordings. There's no shared validator.-### T18b · Concurrent permission edits silently lose one side — MED`IamPolicy` has an etag for exactly this, and the docs promise it triggers ABORTED — but the@@ -192,14 +169,12 @@ constraints.## What I'd do, in order-1. **Make credential rotation fail loudly (T15).** A security operation that returns 200 and does- nothing is worse than one that errors.-2. **Make the extractor's misses loud.** A `Create`/`Update` request whose conventional field is+1. **Make the extractor's misses loud.** A `Create`/`Update` request whose conventional field isabsent still degrades silently to a workspace check — `UpdateDatabaseCatalog` sat that way untilit was found by sweep, not by failure. Rejecting it at startup, the same shape as the`AUTH_METHOD_UNSPECIFIED` gate below, turns the next `catalog`-style field name into a buildfailure instead of a silent scope change.-3. **Fail closed on auth annotations, and put api-linter in CI.** Reject+2. **Fail closed on auth annotations, and put api-linter in CI.** Reject`AUTH_METHOD_UNSPECIFIED` at startup; make a `permission` on a CUSTOM RPC either enforced or abuild error, since 15 are decorative. None of Tier 5 was visible to `buf lint`'s BASIC profile,which is why it accumulated.@@ -222,6 +197,7 @@ constraints.| T18 worksheet write/delete | [#21169](https://github.com/bytebase/bytebase/pull/21169) + [#21181](https://github.com/bytebase/bytebase/pull/21181) — per-verb permissions; SQL Editor Read User can no longer rewrite or delete || T18a | [#21265](https://github.com/bytebase/bytebase/pull/21265) — `BatchCancelTaskRuns` confines its lookup to the plan and environment just authorized; the stage in a task run name is caller-supplied, so cancel rights in one environment reached a RUNNING row in another. An out-of-scope ID is rejected, not dropped — the cancel is driven by the requested IDs || T9 | [#21189](https://github.com/bytebase/bytebase/pull/21189) (self-hosted audit rows) + [#21234](https://github.com/bytebase/bytebase/pull/21234) — one `login_attempt` table bounds password, email-code, and MFA guessing per identity on both deployments, replacing the audit-log counter and the per-code attempt column (which bypassed the resend cooldown). Accepted with it: no per-tenant failed-login record on Cloud, and lockout-as-denial-of-service — see [`login-attempt-lockout.md`](login-attempt-lockout.md) |+| T15 | `update_mask` now decides what each of the four Update methods writes. **`UpdateDataSource`** dispatches the IAM credential on the mask path instead of the request's `authentication_type`, which was unset on any request that masked only the credential — the AIP-134 shape — so rotating a leaked key returned 200 and wrote nothing. The same branch, given a body type that disagreed with the mask, wrote the *other* credential and moved `authentication_type` with it though the mask named neither; the effective type is now resolved from the mask before the loop and a mismatched path is `InvalidArgument`. **`UpdateSetting(APP_IM)`** splices only the masked providers into the stored value rather than assigning the request wholesale, so saving Slack no longer erases the Feishu, WeCom, Lark, DingTalk and Teams secrets; the mask is now required, and a masked provider the payload omits is removed, which is how the console deletes one (it no longer merges the list client-side). **`UpdateIssue`** rejects paths it does not implement instead of returning 200 and dropping them — `status` belongs to `BatchUpdateIssuesStatus` and approvals to `ApproveIssue`/`RejectIssue`, so the supported set was right and only the silence was wrong. **`UpdateDatabaseCatalog`** keeps full-replace semantics and now says so in the proto; its `allow_missing` is removed and the number reserved, because a catalog is not independently creatable — it exists once its database is synced — so the flag had nothing to create, and the ACL's create-permission check on it denied every caller. Both merges were extracted into pure functions (`applyDataSourceUpdateMask`, `mergeAppIMSetting`), so `instance_service_test.go` and `setting_service_test.go` pin the behavior in milliseconds without a server or a metadata database. Accepted with it: the APP_IM mask paths still name no real proto field (`AppIMSetting` holds one repeated `settings`, and `value.app_im_setting_value.teams` is not a field path at all), so they are matched as a fixed vocabulary — making them true paths means restructuring the message one-field-per-provider, which needs a JSONB migration. Also left open, and the reason `UpdateDatabaseCatalog`'s hazard is documented rather than removed: a mask cannot express "this one table" while `schemas` is repeated, and read-modify-write on the catalog and on any IAM policy still loses one side of a concurrent edit, which needs an etag (AIP-154, and T18b) || T14 | [#21267](https://github.com/bytebase/bytebase/pull/21267) — filed as issue paging; the sweep it prompted found the same defect across the class, so it was fixed as a class. Counting endpoints, **17 of the 22** offset-paginated v1 list RPCs were affected; counting the store functions behind them, **14 of 17**. The three already sorting on a total order were `ListQueryHistories` and `ListSavedQueries` (both from one commit, [#21203](https://github.com/bytebase/bytebase/pull/21203), that was never swept across the other lists) and `ListPlans`, which is total only because a mandatory `WHERE plan.project = ?` pins its scope column. Every store list now names tiebreak columns that are unique under its own scope — written into the SQL, and appended after the caller's keys at the six affected lists that accept an `order_by`. The three that were already total are left untouched. Nothing enforces this statically: an earlier revision routed all seventeen through a `buildStableOrderBy` helper so an AST test could require it, but review judged that ceremony and both were removed, so a new paginated list added without a tiebreak will not fail CI. Enforcement is step 4 of `docs/pre-pr-checklist.md` plus review, with `TestPaginationStabilityAcrossProjects` and `TestIssueCommentBatchKeepsInsertionOrder` covering the behavior against a real PostgreSQL. The rules, and the five traps that produced the class — `id` alone in a `(project, id)` table, `created_at` (the *transaction* timestamp, identical across a batch insert), a nullable column, a partial unique index, and an `order_by` that replaces the default ordering rather than adding to it — are in [`backend/store/AGENTS.md`](../../backend/store/AGENTS.md#pagination-ordering). One adjacent bug fixed with it: `ListDatabases`, `ListInstances` and `ListProjects` each threw away the whole clause, tiebreak included, the moment a caller passed `order_by` — which is what broke their paging. Accepted with them: offset paging still drifts under concurrent inserts and deletes (that needs keyset pagination and a page-token change). `ListIssueComment` needed a second fix: its `resource_id` tiebreak is a random UUID, which would have scrambled the activity feed of a multi-field `UpdateIssue`, so `CreateIssueComments` now offsets each row of a batch by its ordinal to keep `created_at` unique and in insertion order. Deliberately out of scope, and worth its own change: `issue.id` is a per-project counter, so ordering a cross-project list by it is not recency — seeded with a three-year-old project and one created today, the newest issue in the new project ranked 4962nd on the default list. Making `create_time` the cross-project default is a product decision. Also left alone: issue search still discards an explicit `order_by` outright when the caller supplied query text || T10 | [#21252](https://github.com/bytebase/bytebase/pull/21252) + [#21258](https://github.com/bytebase/bytebase/pull/21258) — password change and MFA lifecycle move off `UpdateUser` onto their own methods, each requiring a `CredentialProof`: current password, live OTP, recovery code, or a Cloud-only emailed re-auth code. Every proof claims a T9 login-attempt slot, so no proof channel is an unbounded guessing oracle, and a factor-touching method refuses the password while a live factor exists. Accepted with it: **the stolen access token still answers until it expires (≤1h)** — credential generation and the fenced transaction were cut or deferred, password change revokes only the account's web refresh tokens (best-effort, OAuth grants untouched), and an MFA change revokes nothing. What this closes is the credential being *spent* on its own replacement, not the session. Design, and the shipped-vs-designed delta: [`reauthenticate-credential-changes.md`](reauthenticate-credential-changes.md) |diff --git a/frontend/src/routes/workspace/IMPage.tsx b/frontend/src/routes/workspace/IMPage.tsxindex b8cd49f8cc..296651f42a 100644--- a/frontend/src/routes/workspace/IMPage.tsx+++ b/frontend/src/routes/workspace/IMPage.tsx@@ -345,18 +345,17 @@ export function IMPage() {const values = localValues[index] ?? {};setPendingSaveType(typeKey);try {- const reconstructed = createIMSetting(wt, values);- const current = clone(AppIMSettingSchema, getStoredIMSetting());- const existingIdx = current.settings.findIndex((s) => s.type === wt);- if (existingIdx >= 0) {- current.settings[existingIdx] = reconstructed;- } else {- current.settings.push(reconstructed);- }+ // Send only the provider being saved; the server splices it into the+ // stored setting and leaves the others alone.await useAppStore.getState().upsertSetting({name: Setting_SettingName.APP_IM,value: create(SettingValueSchema, {- value: { case: "appIm", value: current },+ value: {+ case: "appIm",+ value: create(AppIMSettingSchema, {+ settings: [createIMSetting(wt, values)],+ }),+ },}),updateMask: create(FieldMaskSchema, { paths: [UPDATE_MASKS[wt]] }),});@@ -377,16 +376,16 @@ export function IMPage() {const stored = getStoredIMSetting();const wasConfigured = stored.settings.some((s) => s.type === wt);if (wasConfigured) {+ // Masking a provider the payload omits removes it.await useAppStore.getState().upsertSetting({name: Setting_SettingName.APP_IM,value: create(SettingValueSchema, {value: {case: "appIm",- value: create(AppIMSettingSchema, {- settings: stored.settings.filter((s) => s.type !== wt),- }),+ value: create(AppIMSettingSchema, { settings: [] }),},}),+ updateMask: create(FieldMaskSchema, { paths: [UPDATE_MASKS[wt]] }),});pushNotification({module: "bytebase",diff --git a/frontend/src/types/proto-es/v1/database_catalog_service_pb.d.ts b/frontend/src/types/proto-es/v1/database_catalog_service_pb.d.tsindex 9a2767f7c5..7509022da7 100644--- a/frontend/src/types/proto-es/v1/database_catalog_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/database_catalog_service_pb.d.ts@@ -38,22 +38,16 @@ export declare const GetDatabaseCatalogRequestSchema: GenMessage<GetDatabaseCata*/export declare type UpdateDatabaseCatalogRequest = Message<"bytebase.v1.UpdateDatabaseCatalogRequest"> & {/**- * The database catalog to update.- *- * The catalog's `name` field is used to identify the database catalog to update.+ * The database catalog to update, identified by its `name` field.* Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog*+ * Replaces the whole catalog: send the complete value, since anything omitted+ * is erased. There is no `update_mask` because `schemas` is a repeated field,+ * and AIP-161 forbids addressing one element of one.+ ** @generated from field: bytebase.v1.DatabaseCatalog catalog = 1;*/catalog?: DatabaseCatalog | undefined;-- /**- * If set to true, and the database catalog is not found, a new database catalog will be created.- * In this situation, `update_mask` is ignored.- *- * @generated from field: bool allow_missing = 2;- */- allowMissing: boolean;};/**diff --git a/frontend/src/types/proto-es/v1/database_catalog_service_pb.js b/frontend/src/types/proto-es/v1/database_catalog_service_pb.jsindex ff656c7091..a5379da0cb 100644--- a/frontend/src/types/proto-es/v1/database_catalog_service_pb.js+++ b/frontend/src/types/proto-es/v1/database_catalog_service_pb.js@@ -13,7 +13,7 @@ import { file_v1_annotation } from "./annotation_pb";* Describes the file v1/database_catalog_service.proto.*/export const file_v1_database_catalog_service = /*@__PURE__*/- fileDesc("CiF2MS9kYXRhYmFzZV9jYXRhbG9nX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIk8KGUdldERhdGFiYXNlQ2F0YWxvZ1JlcXVlc3QSMgoEbmFtZRgBIAEoCUIk4EEC+kEeChxieXRlYmFzZS5jb20vRGF0YWJhc2VDYXRhbG9nImkKHFVwZGF0ZURhdGFiYXNlQ2F0YWxvZ1JlcXVlc3QSMgoHY2F0YWxvZxgBIAEoCzIcLmJ5dGViYXNlLnYxLkRhdGFiYXNlQ2F0YWxvZ0ID4EECEhUKDWFsbG93X21pc3NpbmcYAiABKAgi6gEKD0RhdGFiYXNlQ2F0YWxvZxIMCgRuYW1lGAEgASgJEisKB3NjaGVtYXMYAiADKAsyGi5ieXRlYmFzZS52MS5TY2hlbWFDYXRhbG9nOpsB6kGXAQocYnl0ZWJhc2UuY29tL0RhdGFiYXNlQ2F0YWxvZxIxaW5zdGFuY2VzL3tpbnN0YW5jZX0vZGF0YWJhc2VzL3tkYXRhYmFzZX0vY2F0YWxvZxJEcHJvamVjdHMve3Byb2plY3R9L2luc3RhbmNlcy97aW5zdGFuY2V9L2RhdGFiYXNlcy97ZGF0YWJhc2V9L2NhdGFsb2ciS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FuY2VzLyovZGF0YWJhc2VzLyovY2F0YWxvZ30yMi92MS97Y2F0YWxvZy5uYW1lPWluc3RhbmNlcy8qL2RhdGFiYXNlcy8qL2NhdGFsb2d9QrEBCg9jb20uYnl0ZWJhc2UudjFCG0RhdGFiYXNlQ2F0YWxvZ1NlcnZpY2VQcm90b1ABWjRnaXRodWIuY29tL2J5dGViYXNlL2J5dGViYXNlL2JhY2tlbmQvZ2VuZXJhdGVkLWdvL3YxogIDQlhYqgILQnl0ZWJhc2UuVjHKAgtCeXRlYmFzZVxWMeICF0J5dGViYXNlXFYxXEdQQk1ldGFkYXRh6gIMQnl0ZWJhc2U6OlYxYgZwcm90bzM", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_v1_annotation]);+ fileDesc("CiF2MS9kYXRhYmFzZV9jYXRhbG9nX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIk8KGUdldERhdGFiYXNlQ2F0YWxvZ1JlcXVlc3QSMgoEbmFtZRgBIAEoCUIk4EEC+kEeChxieXRlYmFzZS5jb20vRGF0YWJhc2VDYXRhbG9nImcKHFVwZGF0ZURhdGFiYXNlQ2F0YWxvZ1JlcXVlc3QSMgoHY2F0YWxvZxgBIAEoCzIcLmJ5dGViYXNlLnYxLkRhdGFiYXNlQ2F0YWxvZ0ID4EECSgQIAhADUg1hbGxvd19taXNzaW5nIuoBCg9EYXRhYmFzZUNhdGFsb2cSDAoEbmFtZRgBIAEoCRIrCgdzY2hlbWFzGAIgAygLMhouYnl0ZWJhc2UudjEuU2NoZW1hQ2F0YWxvZzqbAepBlwEKHGJ5dGViYXNlLmNvbS9EYXRhYmFzZUNhdGFsb2cSMWluc3RhbmNlcy97aW5zdGFuY2V9L2RhdGFiYXNlcy97ZGF0YWJhc2V9L2NhdGFsb2cSRHByb2plY3RzL3twcm9qZWN0fS9pbnN0YW5jZXMve2luc3RhbmNlfS9kYXRhYmFzZXMve2RhdGFiYXNlfS9jYXRhbG9nIkgKDV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jIvdjEve2NhdGFsb2cubmFtZT1pbnN0YW5jZXMvKi9kYXRhYmFzZXMvKi9jYXRhbG9nfUKxAQoPY29tLmJ5dGViYXNlLnYxQhtEYXRhYmFzZUNhdGFsb2dTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_v1_annotation]);/*** Describes the message bytebase.v1.GetDatabaseCatalogRequest.diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 45520515b1..c8b3251af4 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -2592,29 +2592,25 @@ paths:required: trueschema:type: string- - name: allowMissing- in: query- description: |-- If set to true, and the database catalog is not found, a new database catalog will be created.- In this situation, `update_mask` is ignored.- schema:- type: boolean- title: allow_missingrequestBody:description: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.content:application/json:schema:title: catalogdescription: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.$ref: '#/components/schemas/bytebase.v1.DatabaseCatalog'responses:"200":@@ -7726,29 +7722,25 @@ paths:required: trueschema:type: string- - name: allowMissing- in: query- description: |-- If set to true, and the database catalog is not found, a new database catalog will be created.- In this situation, `update_mask` is ignored.- schema:- type: boolean- title: allow_missingrequestBody:description: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.content:application/json:schema:title: catalogdescription: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.$ref: '#/components/schemas/bytebase.v1.DatabaseCatalog'responses:"200":@@ -32675,17 +32667,13 @@ components:catalog:title: catalogdescription: |-- The database catalog to update.-- The catalog's `name` field is used to identify the database catalog to update.+ The database catalog to update, identified by its `name` field.Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog++ Replaces the whole catalog: send the complete value, since anything omitted+ is erased. There is no `update_mask` because `schemas` is a repeated field,+ and AIP-161 forbids addressing one element of one.$ref: '#/components/schemas/bytebase.v1.DatabaseCatalog'- allowMissing:- type: boolean- title: allow_missing- description: |-- If set to true, and the database catalog is not found, a new database catalog will be created.- In this situation, `update_mask` is ignored.title: UpdateDatabaseCatalogRequestrequired:- catalogdiff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex b2158ef053..2c789f4494 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -6537,10 +6537,9 @@ Request message for updating a database catalog.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- |-| catalog | [DatabaseCatalog](#bytebase-v1-DatabaseCatalog) | | The database catalog to update.+| catalog | [DatabaseCatalog](#bytebase-v1-DatabaseCatalog) | | The database catalog to update, identified by its `name` field. Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog-The catalog's `name` field is used to identify the database catalog to update. Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog |-| allow_missing | [bool](#bool) | | If set to true, and the database catalog is not found, a new database catalog will be created. In this situation, `update_mask` is ignored. |+Replaces the whole catalog: send the complete value, since anything omitted is erased. There is no `update_mask` because `schemas` is a repeated field, and AIP-161 forbids addressing one element of one. |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 0b3f0a2ed2..14a352b7a0 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -18499,18 +18499,12 @@ Format: instances/{instance}/databases/{database}/catalog or projects/{project}/<td>catalog</td><td><a href="#bytebase.v1.DatabaseCatalog">DatabaseCatalog</a></td><td></td>- <td><p>The database catalog to update.+ <td><p>The database catalog to update, identified by its `name` field.+Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog-The catalog's `name` field is used to identify the database catalog to update.-Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog </p></td>- </tr>-- <tr>- <td>allow_missing</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>If set to true, and the database catalog is not found, a new database catalog will be created.-In this situation, `update_mask` is ignored. </p></td>+Replaces the whole catalog: send the complete value, since anything omitted+is erased. There is no `update_mask` because `schemas` is a repeated field,+and AIP-161 forbids addressing one element of one. </p></td></tr></tbody>diff --git a/proto/v1/v1/database_catalog_service.proto b/proto/v1/v1/database_catalog_service.protoindex 313e034de1..87c0c41e84 100644--- a/proto/v1/v1/database_catalog_service.proto+++ b/proto/v1/v1/database_catalog_service.proto@@ -36,7 +36,7 @@ service DatabaseCatalogService {body: "catalog"}};- option (google.api.method_signature) = "catalog,update_mask";+ option (google.api.method_signature) = "catalog";option (bytebase.v1.permission) = "bb.databaseCatalogs.update";option (bytebase.v1.auth_method) = IAM;option (bytebase.v1.audit) = true;@@ -57,15 +57,18 @@ message GetDatabaseCatalogRequest {// Request message for updating a database catalog.message UpdateDatabaseCatalogRequest {- // The database catalog to update.- //- // The catalog's `name` field is used to identify the database catalog to update.+ // The database catalog to update, identified by its `name` field.// Format: instances/{instance}/databases/{database}/catalog or projects/{project}/instances/{instance}/databases/{database}/catalog+ //+ // Replaces the whole catalog: send the complete value, since anything omitted+ // is erased. There is no `update_mask` because `schemas` is a repeated field,+ // and AIP-161 forbids addressing one element of one.DatabaseCatalog catalog = 1 [(google.api.field_behavior) = REQUIRED];- // If set to true, and the database catalog is not found, a new database catalog will be created.- // In this situation, `update_mask` is ignored.- bool allow_missing = 2;+ // No allow_missing. A catalog is not independently creatable — it exists once+ // its database is synced — so there is nothing for the flag to create.+ reserved 2;+ reserved "allow_missing";}// Catalog metadata for a database including schemas, tables, and columns.