Skip to content

Commit

Permalink
fix: fix recall_app with default app_name
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Mar 11, 2024
1 parent 2bcdaf5 commit 77a1c40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ namespace replication {

using tp_output_format = ::dsn::utils::table_printer::output_format;

error_s replication_ddl_client::validate_app_name(const std::string &app_name)
error_s replication_ddl_client::validate_app_name(const std::string &app_name,
bool allow_empty_name)
{
if (app_name.empty() || !std::all_of(app_name.cbegin(), app_name.cend(), [](const char c) {
if ((app_name.empty() && !allow_empty_name) ||
!std::all_of(app_name.cbegin(), app_name.cend(), [](const char c) {
return static_cast<bool>(std::isalnum(c)) || c == '_' || c == '.' || c == ':';
})) {
return FMT_ERR(ERR_INVALID_PARAMETERS, "Invalid name: Only 0-9a-zA-Z.:_ are valid.");
Expand Down Expand Up @@ -227,8 +229,7 @@ dsn::error_code replication_ddl_client::drop_app(const std::string &app_name, in
dsn::error_code replication_ddl_client::recall_app(int32_t app_id, const std::string &new_app_name)
{
RETURN_EC_NOT_OK_MSG(
validate_app_name(new_app_name), "invalid new_app_name: '{}'", new_app_name);

validate_app_name(new_app_name, true), "invalid new_app_name: '{}'", new_app_name);
auto req = std::make_shared<configuration_recall_app_request>();
req->app_id = app_id;
req->new_app_name = new_app_name;
Expand Down
2 changes: 1 addition & 1 deletion src/client/replication_ddl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class replication_ddl_client

void set_max_wait_app_ready_secs(uint32_t max_wait_secs) { _max_wait_secs = max_wait_secs; }

static error_s validate_app_name(const std::string &app_name);
static error_s validate_app_name(const std::string &app_name, bool allow_empty_name = false);

private:
bool static valid_app_char(int c);
Expand Down

0 comments on commit 77a1c40

Please sign in to comment.