diff --git a/changelog/17.0/17.0.0/summary.md b/changelog/17.0/17.0.0/summary.md index 01bde438688..1c1ec2e1daa 100644 --- a/changelog/17.0/17.0.0/summary.md +++ b/changelog/17.0/17.0.0/summary.md @@ -5,6 +5,7 @@ - **[Major Changes](#major-changes)** - **[Breaking Changes](#breaking-changes)** - [Dedicated stats for VTGate Prepare operations](#dedicated-vtgate-prepare-stats) + - [Keyspace name validation in TopoServer](#keyspace-name-validation) - **[New command line flags and behavior](#new-flag)** - [Builtin backup: read buffering flags](#builtin-backup-read-buffering-flags) - **[New stats](#new-stats)** @@ -49,6 +50,16 @@ Here is a (condensed) example of stats output: } ``` + +#### Keyspace name validation in TopoServer + +Prior to v17, it was possible to create a keyspace with invalid characters, which would then be inaccessible to various cluster management operations. + +Now, the TopoServer's `GetKeyspace` and `CreateKeyspace` methods return an error if given an invalid name. + +Keyspace names may no longer contain the following characters: +- Forward slash ("/"). + ### New command line flags and behavior #### Backup --builtinbackup-file-read-buffer-size and --builtinbackup-file-write-buffer-size diff --git a/go/vt/topo/keyspace.go b/go/vt/topo/keyspace.go index 14a9563db87..ccf1ed23dcd 100755 --- a/go/vt/topo/keyspace.go +++ b/go/vt/topo/keyspace.go @@ -56,6 +56,14 @@ func (ki *KeyspaceInfo) SetKeyspaceName(name string) { var ksNameReplacer = strings.NewReplacer("/", "") +// ValidateKeyspaceNames checks if the provided name is a valid name for a +// keyspace. +// +// If it is valid, the original name is returned with no error. If it is +// invalid, the name with all invalid characters removed is returned, along +// with an error. +// +// As of v17, "all invalid characters" is just the forward slash ("/"). func ValidateKeyspaceName(name string) (string, error) { if validated := ksNameReplacer.Replace(name); name != validated { return validated, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "keyspace name %s contains invalid characters; expected %s instead", name, validated)