Copilot commented on code in PR #63527:
URL: https://github.com/apache/doris/pull/63527#discussion_r3308078137


##########
cloud/src/recycler/recycler_service.cpp:
##########
@@ -507,204 +508,43 @@ void 
RecyclerServiceImpl::http(::google::protobuf::RpcController* controller,
                                const ::doris::cloud::MetaServiceHttpRequest* 
request,
                                ::doris::cloud::MetaServiceHttpResponse* 
response,
                                ::google::protobuf::Closure* done) {
-    auto cntl = static_cast<brpc::Controller*>(controller);
-    LOG(INFO) << "rpc from " << cntl->remote_side() << " request: " << 
request->DebugString();
+    auto* cntl = static_cast<brpc::Controller*>(controller);
+    LOG(INFO) << "rpc from " << cntl->remote_side()
+              << " request: " << cntl->http_request().uri().path();
     brpc::ClosureGuard closure_guard(done);
-    MetaServiceCode code = MetaServiceCode::OK;
-    int status_code = 200;
-    std::string msg = "OK";
-    std::string req;
-    std::string response_body;
-    std::string request_body;
-    DORIS_CLOUD_DEFER {
-        status_code = std::get<0>(convert_ms_code_to_http_code(code));
-        LOG(INFO) << (code == MetaServiceCode::OK ? "succ to " : "failed to ") 
<< "http"
-                  << " " << cntl->remote_side() << " request=\n"
-                  << req << "\n ret=" << code << " msg=" << msg;
-        cntl->http_response().set_status_code(status_code);
-        cntl->response_attachment().append(response_body);
+    const auto& unresolved_path = cntl->http_request().unresolved_path();
+    auto api_path = split_http_api_path(unresolved_path);
+    const auto& handlers = get_http_handlers();
+    auto it = handlers.find(api_path.route);
+    const auto* handler =
+            it == handlers.end() ? nullptr : resolve_http_handler(it->second, 
api_path.version);
+    if (handler == nullptr ||
+        (it->second.role != HttpRole::RECYCLER && it->second.role != 
HttpRole::BOTH)) {
+        std::string msg = "http path not found or not allowed";
+        cntl->http_response().set_status_code(404);
+        cntl->response_attachment().append(msg);
         cntl->response_attachment().append("\n");
-    };
-
-    // Prepare input request info
-    auto unresolved_path = cntl->http_request().unresolved_path();
-    auto uri = cntl->http_request().uri();
-    std::stringstream ss;
-    ss << "\nuri_path=" << uri.path();
-    ss << "\nunresolved_path=" << unresolved_path;
-    ss << "\nmethod=" << brpc::HttpMethod2Str(cntl->http_request().method());
-    ss << "\nquery strings:";
-    for (auto it = uri.QueryBegin(); it != uri.QueryEnd(); ++it) {
-        ss << "\n" << it->first << "=" << it->second;
-    }
-    ss << "\nheaders:";
-    for (auto it = cntl->http_request().HeaderBegin(); it != 
cntl->http_request().HeaderEnd();
-         ++it) {
-        ss << "\n" << it->first << ":" << it->second;
+        return;
     }
-    req = ss.str();
-    ss.clear();
-    request_body = cntl->request_attachment().to_string(); // Just copy
 
     // Auth
-    auto token = uri.GetQuery("token");
+    const auto* token = cntl->http_request().uri().GetQuery("token");
     if (token == nullptr || *token != config::http_token) {
-        msg = "incorrect token, token=" + (token == nullptr ? 
std::string("(not given)") : *token);
-        response_body = "incorrect token";
-        status_code = 403;
-        return;
-    }
-
-    if (unresolved_path == "recycle_instance") {
-        RecycleInstanceRequest req;
-        auto st = google::protobuf::util::JsonStringToMessage(request_body, 
&req);
-        if (!st.ok()) {
-            msg = "failed to RecycleInstanceRequest, error: " + 
st.message().ToString();
-            response_body = msg;
-            LOG(WARNING) << msg;
-            return;
-        }
-        RecycleInstanceResponse res;
-        recycle_instance(cntl, &req, &res, nullptr);
-        code = res.status().code();
-        msg = res.status().msg();
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "statistics_recycle") {
-        StatisticsRecycleRequest req;
-        auto st = google::protobuf::util::JsonStringToMessage(request_body, 
&req);
-        if (!st.ok()) {
-            msg = "failed to StatisticsRecycleRequest, error: " + 
st.message().ToString();
-            response_body = msg;
-            LOG(WARNING) << msg;
-            return;
-        }
-        statistics_recycle(req, code, msg);
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "recycle_copy_jobs") {
-        auto instance_id = uri.GetQuery("instance_id");
-        if (instance_id == nullptr || instance_id->empty()) {
-            msg = "no instance id";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        recycle_copy_jobs(txn_kv_, *instance_id, code, msg, 
recycler_->_thread_pool_group,
-                          txn_lazy_committer_);
-
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "recycle_job_info") {
-        auto instance_id = uri.GetQuery("instance_id");
-        if (instance_id == nullptr || instance_id->empty()) {
-            msg = "no instance id";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        std::string key;
-        job_recycle_key({*instance_id}, &key);
-        recycle_job_info(txn_kv_, *instance_id, key, code, msg);
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "check_instance") {
-        auto instance_id = uri.GetQuery("instance_id");
-        if (instance_id == nullptr || instance_id->empty()) {
-            msg = "no instance id";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        if (!checker_) {
-            msg = "checker not enabled";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        check_instance(*instance_id, code, msg);
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "check_job_info") {
-        auto instance_id = uri.GetQuery("instance_id");
-        if (instance_id == nullptr || instance_id->empty()) {
-            msg = "no instance id";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        std::string key;
-        job_check_key({*instance_id}, &key);
-        recycle_job_info(txn_kv_, *instance_id, key, code, msg);
-        response_body = msg;
-        return;
-    }
-
-    if (unresolved_path == "check_meta") {
-        auto instance_id = uri.GetQuery("instance_id");
-        auto host = uri.GetQuery("host");
-        auto port = uri.GetQuery("port");
-        auto user = uri.GetQuery("user");
-        auto password = uri.GetQuery("password");
-        if (instance_id == nullptr || instance_id->empty() || host == nullptr 
|| host->empty() ||
-            port == nullptr || port->empty() || password == nullptr || user == 
nullptr ||
-            user->empty()) {
-            msg = "no instance id or mysql conn str info";
-            response_body = msg;
-            status_code = 400;
-            return;
-        }
-        LOG(INFO) << " host " << *host;
-        LOG(INFO) << " port " << *port;
-        LOG(INFO) << " user " << *user;
-        LOG(INFO) << " instance " << *instance_id;
-        check_meta(txn_kv_, *instance_id, *host, *port, *user, *password, msg);
-        status_code = 200;
-        response_body = msg;
+        std::string msg = "incorrect token, token=" +
+                          (token == nullptr ? std::string("(not given)") : 
*token);
+        cntl->http_response().set_status_code(403);
+        cntl->response_attachment().append(msg);
+        cntl->response_attachment().append("\n");
+        LOG(WARNING) << "failed to handle http from " << cntl->remote_side() 
<< " msg: " << msg;

Review Comment:
   The 403 response/log message echoes the provided `token` value (`incorrect 
token, token=...`). This leaks secrets into responses and logs. Return a 
generic "incorrect token" message and avoid logging the raw token (log only 
that auth failed, or a redacted/hashed token if needed).



##########
cloud/src/meta-service/meta_service_http.cpp:
##########
@@ -980,15 +191,18 @@ void 
MetaServiceImpl::http(::google::protobuf::RpcController* controller,
         return;
     }
 
-    // Process http request
-    auto& unresolved_path = cntl->http_request().unresolved_path();
-    HttpHandler handler = process_unknown;
-    auto it = http_handlers.find(unresolved_path);
-    if (it != http_handlers.end()) {
-        handler = it->second;
+    const auto* handler =
+            it == handlers.end() ? nullptr : resolve_http_handler(it->second, 
api_path.version);
+    if (handler == nullptr ||
+        (it->second.role != HttpRole::META_SERVICE && it->second.role != 
HttpRole::BOTH)) {
+        std::string msg = "http path not found or not allowed";
+        cntl->http_response().set_status_code(404);
+        cntl->response_attachment().append(msg);
+        cntl->response_attachment().append("\n");

Review Comment:
   This changes unknown/unregistered HTTP routes from the previous "always OK" 
compatibility behavior to a hard 404. If older/newer cloud-manager components 
rely on the old behavior for forward-compatibility, this becomes a breaking 
change. Consider restoring the compatibility fallback (e.g., return OK for 
unknown routes, or gate 404 behind a config/feature flag) or document the 
behavior change explicitly.
   



##########
cloud/src/common/http_helper.cpp:
##########
@@ -0,0 +1,1184 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "http_helper.h"
+
+#include <brpc/controller.h>
+#include <brpc/http_status_code.h>
+#include <brpc/uri.h>
+#include <fmt/core.h>
+#include <fmt/format.h>
+#include <gen_cpp/cloud.pb.h>
+#include <glog/logging.h>
+#include <google/protobuf/message.h>
+#include <google/protobuf/service.h>
+#include <google/protobuf/util/json_util.h>
+#include <rapidjson/document.h>
+#include <rapidjson/error/en.h>
+#include <rapidjson/prettywriter.h>
+#include <rapidjson/stringbuffer.h>
+
+#include <algorithm>
+#include <cstdint>
+#include <string>
+#include <type_traits>
+
+#include "common/metric.h"
+#include "cpp/s3_rate_limiter.h"
+#include "meta-service/meta_service.h"
+#include "meta-service/meta_service_helper.h"
+#include "meta-service/meta_service_http.h"
+#include "recycler/recycler.h"
+#include "recycler/recycler_service.h"
+namespace doris::cloud {
+
+template <typename Message>
+static google::protobuf::util::Status parse_json_message(const std::string& 
unresolved_path,
+                                                         const std::string& 
body, Message* req) {
+    static_assert(std::is_base_of_v<google::protobuf::Message, Message>);
+    auto st = google::protobuf::util::JsonStringToMessage(body, req);
+    if (!st.ok()) {
+        std::string msg = "failed to strictly parse http request for '" + 
unresolved_path +
+                          "' error: " + st.ToString();
+        LOG_WARNING(msg).tag("body", encryt_sk(hide_access_key(body)));
+
+        // ignore unknown fields
+        google::protobuf::util::JsonParseOptions json_parse_options;
+        json_parse_options.ignore_unknown_fields = true;
+        return google::protobuf::util::JsonStringToMessage(body, req, 
json_parse_options);
+    }
+    return {};
+}
+
+#define PARSE_MESSAGE_OR_RETURN(ctrl, req)                                     
                 \
+    do {                                                                       
                 \
+        std::string body = ctrl->request_attachment().to_string();             
                 \
+        auto& unresolved_path = ctrl->http_request().unresolved_path();        
                 \
+        auto st = parse_json_message(unresolved_path, body, &req);             
                 \
+        if (!st.ok()) {                                                        
                 \
+            std::string msg = "parse http request '" + unresolved_path + "': " 
+ st.ToString(); \
+            LOG_WARNING(msg).tag("body", encryt_sk(hide_access_key(body)));    
                 \
+            return http_json_reply(MetaServiceCode::PROTOBUF_PARSE_ERR, msg);  
                 \
+        }                                                                      
                 \
+    } while (0)
+
+const std::unordered_map<std::string_view, HttpHandlerInfo>& 
get_http_handlers() {
+    using MS = MetaServiceImpl;
+    using RS = RecyclerServiceImpl;
+
+    static const auto handlers = [] {
+        return std::unordered_map<std::string_view, HttpHandlerInfo> {
+                // MetaService APIs
+                {"add_cluster",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_cluster",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"rename_cluster",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"update_cluster_endpoint",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"update_cluster_mysql_user_name",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"add_node",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_node",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"decommission_node",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"set_cluster_status",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"notify_decommissioned",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"alter_vcluster_info",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+
+                {"create_instance",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_create_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_instance",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"rename_instance",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"enable_instance_sse",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"disable_instance_sse",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"set_instance_status",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_instance((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+
+                {"add_obj_info",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_obj_store_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"legacy_update_ak_sk",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_obj_store_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"update_ak_sk",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_update_ak_sk((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"show_storage_vaults",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_obj_store_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"add_hdfs_vault",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_storage_vault((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"add_s3_vault",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_storage_vault((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"alter_s3_vault",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_storage_vault((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_s3_vault",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_storage_vault((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_hdfs_vault",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_storage_vault((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"alter_obj_info",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_alter_obj_store_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+
+                {"decode_key",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_decode_key((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"encode_key",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_encode_key((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_value",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_get_value((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"set_value",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_set_value((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"show_meta_ranges",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_show_meta_ranges((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"txn_lazy_commit",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_txn_lazy_commit((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"injection_point",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_injection_point((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"fix_tablet_stats",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_fix_tablet_stats((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"fix_tablet_db_id",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_fix_tablet_db_id((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+
+                {"get_instance",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_instance_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_obj_store_info",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_obj_store_info((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_cluster",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_get_cluster((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_tablet_stats",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_tablet_stats((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_stage",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_get_stage((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_cluster_status",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_cluster_status((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+
+                {"list_snapshot",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_list_snapshot((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"drop_snapshot",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_drop_snapshot((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"set_snapshot_property",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_set_snapshot_property((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"get_snapshot_property",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_get_snapshot_property((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"set_multi_version_status",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_set_multi_version_status((MS*)s, 
c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"abort_txn",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_abort_txn((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"abort_tablet_job",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_abort_tablet_job((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"alter_ram_user",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_ram_user((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"alter_iam",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_alter_iam((MS*)s, c); },
+                  .role = HttpRole::META_SERVICE}},
+                {"adjust_rate_limit",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_adjust_rate_limit((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+                {"list_rate_limit",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_query_rate_limit((MS*)s, c);
+                          },
+                  .role = HttpRole::META_SERVICE}},
+
+                // Recycler APIs
+                {"recycle_instance",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_recycle_instance((RS*)s, c);
+                          },
+                  .role = HttpRole::RECYCLER}},
+                {"statistics_recycle",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_statistics_recycle((RS*)s, c);
+                          },
+                  .role = HttpRole::RECYCLER}},
+                {"recycle_copy_jobs",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_recycle_copy_jobs((RS*)s, c);
+                          },
+                  .role = HttpRole::RECYCLER}},
+                {"recycle_job_info",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_recycle_job_info((RS*)s, c);
+                          },
+                  .role = HttpRole::RECYCLER}},
+                {"check_instance",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_check_instance((RS*)s, c); },
+                  .role = HttpRole::RECYCLER}},
+                {"check_job_info",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_check_job_info((RS*)s, c); },
+                  .role = HttpRole::RECYCLER}},
+                {"check_meta",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_check_meta((RS*)s, c); },
+                  .role = HttpRole::RECYCLER}},
+                {"adjust_rate_limiter",
+                 {.handler =
+                          [](void* s, brpc::Controller* c) {
+                              return process_adjust_rate_limiter((RS*)s, c);
+                          },
+                  .role = HttpRole::RECYCLER}},
+
+                // Shared APIs
+                {"show_config",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_show_config((MS*)s, c); },
+                  .role = HttpRole::BOTH}},
+                {"update_config",
+                 {.handler = [](void* s,
+                                brpc::Controller* c) { return 
process_update_config((MS*)s, c); },

Review Comment:
   `show_config`/`update_config` are registered with `HttpRole::BOTH`, but the 
handler lambdas cast `void* s` to `MetaServiceImpl*`. When these routes are 
served by `RecyclerServiceImpl::http`, `s` will actually be a 
`RecyclerServiceImpl*`, so this cast is invalid and can lead to undefined 
behavior (and future crashes if the handler starts using `service`). Use a 
role-appropriate wrapper (e.g., separate handlers for recycler vs meta-service) 
or make these handlers not depend on a `MetaServiceImpl*` (e.g., accept `void*` 
and avoid the cast).
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to