mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(rds): accept the master usernames each engine really allows (#3730)
The 16 character cap was applied to every engine, but RDS accepts 63 on PostgreSQL and 32 on MySQL, so an instance whose master username is longer could not be created at all. The bound now comes from DatabaseEngine, using the engine createDbInstance already resolves; the character rule and the error message are unchanged. Closes #3729
This commit is contained in:
1 parent
f99e507916
commit
f48bc2aa40
4 files changed
+74
-2
No files matched your search
@@ -611,7 +611,8 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
int proxyPort = allocateProxyPort();
|
||||
if (masterUsername == null || masterUsername.isBlank()) {
|
||||
masterUsername = "root";
|
||||
} else if (masterUsername.length() > 16 || !masterUsername.matches("^[a-zA-Z][a-zA-Z0-9_]*$")) {
|
||||
} else if (masterUsername.length() > engine.maxMasterUsernameLength()
|
||||
|| !masterUsername.matches("^[a-zA-Z][a-zA-Z0-9_]*$")) {
|
||||
throw new AwsException("InvalidParameterValue",
|
||||
"MasterUsername must begin with a letter and contain only alphanumeric characters or underscores.", 400);
|
||||
}
|
||||
|
||||
@@ -12,4 +12,14 @@ public enum DatabaseEngine {
|
||||
case MYSQL, MARIADB -> 3306;
|
||||
};
|
||||
}
|
||||
|
||||
// The API reference documents 16 characters for every engine, but RDS accepts longer
|
||||
// master usernames on PostgreSQL and MySQL. These are the limits the service enforces.
|
||||
public int maxMasterUsernameLength() {
|
||||
return switch (this) {
|
||||
case POSTGRES -> 63;
|
||||
case MYSQL -> 32;
|
||||
case MARIADB -> 16;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user