Copilot commented on code in PR #1071:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1071#discussion_r4454264933


##########
admin/logic/legacy_resource.go:
##########
@@ -0,0 +1,688 @@
+/*
+ * 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.
+ */
+
+package logic
+
+import (
+       "context"
+       "errors"
+       "fmt"
+       "regexp"
+       "sort"
+       "strconv"
+       "strings"
+)
+
+import (
+       clientv3 "go.etcd.io/etcd/client/v3"
+)
+
+import (
+       adminconfig "github.com/apache/dubbo-go-pixiu/admin/config"
+       commonyaml "github.com/apache/dubbo-go-pixiu/pkg/common/yaml"
+       "github.com/apache/dubbo-go-pixiu/pkg/config"
+)
+
+const legacyResources = "resources"
+
+func legacyResourceKey(id string, unpublished bool) string {
+       if unpublished {
+               return getUnpublishedRootPath(legacyResources) + "/" + id
+       }
+       return getRootPath(legacyResources) + "/" + id
+}
+
+func legacyMethodPrefix(resourceID string, unpublished bool) string {
+       return legacyResourceKey(resourceID, unpublished) + "/" + Method
+}
+
+func legacyMethodKey(resourceID, methodID string, unpublished bool) string {
+       return legacyMethodPrefix(resourceID, unpublished) + "/" + methodID
+}
+
+func legacyResourceKeyPattern(unpublished bool) *regexp.Regexp {
+       root := getRootPath(legacyResources)
+       if unpublished {
+               root = getUnpublishedRootPath(legacyResources)
+       }
+       return regexp.MustCompile("^" + regexp.QuoteMeta(root) + `/[^/]+/?$`)
+}
+
+// BizGetResourceList restores the original Resource API over the runtime key
+// layout. RouteBinding records are not included because they use a separate
+// namespace and are compiled to these keys only when published.
+func BizGetResourceList(unpublished bool) ([]config.Resource, error) {
+       keys, values, err := adminconfig.Client.GetChildrenKVList(func() string 
{
+               if unpublished {
+                       return getUnpublishedRootPath(legacyResources)
+               }
+               return getRootPath(legacyResources)
+       }())
+       if err != nil {
+               return nil, err
+       }
+       if len(keys) != len(values) {
+               return nil, fmt.Errorf("legacy resource key/value count 
mismatch: %d != %d", len(keys), len(values))
+       }
+       resources := make([]config.Resource, 0, len(values))
+       pattern := legacyResourceKeyPattern(unpublished)
+       for index, key := range keys {
+               if !pattern.MatchString(key) {
+                       continue
+               }
+               var resource config.Resource
+               if err := commonyaml.UnmarshalYML([]byte(values[index]), 
&resource); err != nil {
+                       return nil, fmt.Errorf("decode legacy resource %q: %w", 
key, err)
+               }
+               resources = append(resources, resource)
+       }
+       return resources, nil
+}
+
+func BizGetResourceDetail(id string, unpublished bool) (string, error) {
+       return adminconfig.Client.Get(legacyResourceKey(id, unpublished))
+}
+
+// BizResourceExists checks an exact legacy Resource key without conflating a
+// missing record with an etcd read failure.
+func BizResourceExists(id string, unpublished bool) (bool, error) {
+       id, err := normalizePositiveLegacyID(id, ResourceID)
+       if err != nil {
+               return false, err
+       }
+       if adminconfig.Client == nil {
+               return false, errors.New("admin etcd client is unavailable")
+       }
+       client := adminconfig.Client.GetRawClient()
+       if client == nil {
+               return false, errors.New("admin etcd client is unavailable")
+       }
+       response, err := client.Get(adminconfig.Client.GetCtx(), 
legacyResourceKey(id, unpublished))
+       if err != nil {
+               return false, fmt.Errorf("read legacy resource %q: %w", id, err)
+       }
+       return len(response.Kvs) > 0, nil
+}
+
+func BizSetResourceInfo(resource *config.Resource, created, unpublished bool) 
error {
+       if resource == nil {
+               return errors.New("legacy resource is nil")
+       }
+       methods := append([]config.Method(nil), resource.Methods...)
+       storedResource := *resource
+       storedResource.Methods = nil
+       if created && storedResource.ID <= 0 {
+               storedResource.ID = nextLegacyResourceID()
+               if storedResource.ID <= 0 {
+                       return errors.New("could not allocate legacy resource 
id")
+               }
+       } else if storedResource.ID <= 0 {
+               return errors.New("legacy resource id must be positive")
+       }
+       resource.ID = storedResource.ID
+       data, err := commonyaml.MarshalYML(storedResource)
+       if err != nil {
+               return fmt.Errorf("encode legacy resource: %w", err)
+       }
+       key := legacyResourceKey(strconv.Itoa(storedResource.ID), unpublished)
+       if unpublished {
+               if created {
+                       err = adminconfig.Client.Create(key, string(data))
+               } else {
+                       err = adminconfig.Client.Update(key, string(data))
+               }
+               if err != nil {
+                       return fmt.Errorf("save legacy resource: %w", err)
+               }
+               if created {
+                       for index := range methods {
+                               methods[index].ResourcePath = 
storedResource.Path
+                               if err := 
BizSetResourceMethod(strconv.Itoa(storedResource.ID), &methods[index], true, 
unpublished); err != nil {
+                                       return err
+                               }
+                               resource.Methods[index] = methods[index]
+                       }
+               }
+               return nil
+       }
+
+       operations := []clientv3.Op{clientv3.OpPut(key, string(data))}
+       comparisons := make([]clientv3.Cmp, 0, len(methods)+1)
+       if created {
+               comparisons = append(comparisons, 
clientv3.Compare(clientv3.CreateRevision(key), "=", 0))
+               for index := range methods {
+                       if methods[index].ID <= 0 {
+                               methods[index].ID = nextLegacyMethodID()
+                               if methods[index].ID <= 0 {
+                                       return errors.New("could not allocate 
legacy method id")
+                               }
+                       }
+                       methods[index].ResourcePath = storedResource.Path
+                       methodData, err := commonyaml.MarshalYML(methods[index])
+                       if err != nil {
+                               return fmt.Errorf("encode legacy method: %w", 
err)
+                       }
+                       methodKey := 
legacyMethodKey(strconv.Itoa(storedResource.ID), 
strconv.Itoa(methods[index].ID), false)
+                       operations = append(operations, 
clientv3.OpPut(methodKey, string(methodData)))
+                       comparisons = append(comparisons, 
clientv3.Compare(clientv3.CreateRevision(methodKey), "=", 0))
+                       resource.Methods[index] = methods[index]
+               }
+       }
+       if err := publishLegacyResourceOperations(operations, comparisons...); 
err != nil {
+               return fmt.Errorf("save legacy resource: %w", err)
+       }
+       return nil
+}
+
+func BizDeleteResourceInfo(id string, unpublished bool) error {
+       id, err := normalizePositiveLegacyID(id, ResourceID)
+       if err != nil {
+               return err
+       }
+       if adminconfig.Client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+       client := adminconfig.Client.GetRawClient()
+       if client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+       key := legacyResourceKey(id, unpublished)
+       return deleteLegacyResource(adminconfig.Client.GetCtx(), client, key)

Review Comment:
   Legacy clients can delete an AdminRouteBinding's generated Resource or 
Method, taking the route offline while its published status and history remain 
unchanged. Reject binding-owned IDs with an ownership check protected by the 
publication-generation comparison in the delete transaction, or delegate to the 
binding deletion lifecycle. The same issue occurs in 
`admin/logic/legacy_resource.go:339` for Method deletion.



##########
admin/logic/legacy_resource.go:
##########
@@ -0,0 +1,688 @@
+/*
+ * 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.
+ */
+
+package logic
+
+import (
+       "context"
+       "errors"
+       "fmt"
+       "regexp"
+       "sort"
+       "strconv"
+       "strings"
+)
+
+import (
+       clientv3 "go.etcd.io/etcd/client/v3"
+)
+
+import (
+       adminconfig "github.com/apache/dubbo-go-pixiu/admin/config"
+       commonyaml "github.com/apache/dubbo-go-pixiu/pkg/common/yaml"
+       "github.com/apache/dubbo-go-pixiu/pkg/config"
+)
+
+const legacyResources = "resources"
+
+func legacyResourceKey(id string, unpublished bool) string {
+       if unpublished {
+               return getUnpublishedRootPath(legacyResources) + "/" + id
+       }
+       return getRootPath(legacyResources) + "/" + id
+}
+
+func legacyMethodPrefix(resourceID string, unpublished bool) string {
+       return legacyResourceKey(resourceID, unpublished) + "/" + Method
+}
+
+func legacyMethodKey(resourceID, methodID string, unpublished bool) string {
+       return legacyMethodPrefix(resourceID, unpublished) + "/" + methodID
+}
+
+func legacyResourceKeyPattern(unpublished bool) *regexp.Regexp {
+       root := getRootPath(legacyResources)
+       if unpublished {
+               root = getUnpublishedRootPath(legacyResources)
+       }
+       return regexp.MustCompile("^" + regexp.QuoteMeta(root) + `/[^/]+/?$`)
+}
+
+// BizGetResourceList restores the original Resource API over the runtime key
+// layout. RouteBinding records are not included because they use a separate
+// namespace and are compiled to these keys only when published.
+func BizGetResourceList(unpublished bool) ([]config.Resource, error) {
+       keys, values, err := adminconfig.Client.GetChildrenKVList(func() string 
{
+               if unpublished {
+                       return getUnpublishedRootPath(legacyResources)
+               }
+               return getRootPath(legacyResources)
+       }())
+       if err != nil {
+               return nil, err
+       }
+       if len(keys) != len(values) {
+               return nil, fmt.Errorf("legacy resource key/value count 
mismatch: %d != %d", len(keys), len(values))
+       }
+       resources := make([]config.Resource, 0, len(values))
+       pattern := legacyResourceKeyPattern(unpublished)
+       for index, key := range keys {
+               if !pattern.MatchString(key) {
+                       continue
+               }
+               var resource config.Resource
+               if err := commonyaml.UnmarshalYML([]byte(values[index]), 
&resource); err != nil {
+                       return nil, fmt.Errorf("decode legacy resource %q: %w", 
key, err)
+               }
+               resources = append(resources, resource)
+       }
+       return resources, nil
+}
+
+func BizGetResourceDetail(id string, unpublished bool) (string, error) {
+       return adminconfig.Client.Get(legacyResourceKey(id, unpublished))
+}
+
+// BizResourceExists checks an exact legacy Resource key without conflating a
+// missing record with an etcd read failure.
+func BizResourceExists(id string, unpublished bool) (bool, error) {
+       id, err := normalizePositiveLegacyID(id, ResourceID)
+       if err != nil {
+               return false, err
+       }
+       if adminconfig.Client == nil {
+               return false, errors.New("admin etcd client is unavailable")
+       }
+       client := adminconfig.Client.GetRawClient()
+       if client == nil {
+               return false, errors.New("admin etcd client is unavailable")
+       }
+       response, err := client.Get(adminconfig.Client.GetCtx(), 
legacyResourceKey(id, unpublished))
+       if err != nil {
+               return false, fmt.Errorf("read legacy resource %q: %w", id, err)
+       }
+       return len(response.Kvs) > 0, nil
+}
+
+func BizSetResourceInfo(resource *config.Resource, created, unpublished bool) 
error {
+       if resource == nil {
+               return errors.New("legacy resource is nil")
+       }
+       methods := append([]config.Method(nil), resource.Methods...)
+       storedResource := *resource
+       storedResource.Methods = nil
+       if created && storedResource.ID <= 0 {
+               storedResource.ID = nextLegacyResourceID()
+               if storedResource.ID <= 0 {
+                       return errors.New("could not allocate legacy resource 
id")
+               }
+       } else if storedResource.ID <= 0 {
+               return errors.New("legacy resource id must be positive")
+       }
+       resource.ID = storedResource.ID
+       data, err := commonyaml.MarshalYML(storedResource)
+       if err != nil {
+               return fmt.Errorf("encode legacy resource: %w", err)
+       }
+       key := legacyResourceKey(strconv.Itoa(storedResource.ID), unpublished)
+       if unpublished {
+               if created {
+                       err = adminconfig.Client.Create(key, string(data))
+               } else {
+                       err = adminconfig.Client.Update(key, string(data))
+               }
+               if err != nil {
+                       return fmt.Errorf("save legacy resource: %w", err)
+               }
+               if created {
+                       for index := range methods {
+                               methods[index].ResourcePath = 
storedResource.Path
+                               if err := 
BizSetResourceMethod(strconv.Itoa(storedResource.ID), &methods[index], true, 
unpublished); err != nil {
+                                       return err
+                               }
+                               resource.Methods[index] = methods[index]
+                       }
+               }
+               return nil
+       }
+
+       operations := []clientv3.Op{clientv3.OpPut(key, string(data))}
+       comparisons := make([]clientv3.Cmp, 0, len(methods)+1)
+       if created {
+               comparisons = append(comparisons, 
clientv3.Compare(clientv3.CreateRevision(key), "=", 0))
+               for index := range methods {
+                       if methods[index].ID <= 0 {
+                               methods[index].ID = nextLegacyMethodID()
+                               if methods[index].ID <= 0 {
+                                       return errors.New("could not allocate 
legacy method id")
+                               }
+                       }
+                       methods[index].ResourcePath = storedResource.Path
+                       methodData, err := commonyaml.MarshalYML(methods[index])
+                       if err != nil {
+                               return fmt.Errorf("encode legacy method: %w", 
err)
+                       }
+                       methodKey := 
legacyMethodKey(strconv.Itoa(storedResource.ID), 
strconv.Itoa(methods[index].ID), false)
+                       operations = append(operations, 
clientv3.OpPut(methodKey, string(methodData)))
+                       comparisons = append(comparisons, 
clientv3.Compare(clientv3.CreateRevision(methodKey), "=", 0))
+                       resource.Methods[index] = methods[index]
+               }
+       }
+       if err := publishLegacyResourceOperations(operations, comparisons...); 
err != nil {
+               return fmt.Errorf("save legacy resource: %w", err)
+       }
+       return nil
+}
+
+func BizDeleteResourceInfo(id string, unpublished bool) error {
+       id, err := normalizePositiveLegacyID(id, ResourceID)
+       if err != nil {
+               return err
+       }
+       if adminconfig.Client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+       client := adminconfig.Client.GetRawClient()
+       if client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+       key := legacyResourceKey(id, unpublished)
+       return deleteLegacyResource(adminconfig.Client.GetCtx(), client, key)
+}
+
+func deleteLegacyResource(ctx context.Context, kv routeBindingKV, key string) 
error {
+       _, err := kv.Txn(ctx).Then(
+               clientv3.OpDelete(key),
+               clientv3.OpDelete(key+"/", clientv3.WithPrefix()),
+       ).Commit()
+       return err
+}
+
+func BizGetMethodList(resourceID string, unpublished bool) ([]config.Method, 
error) {
+       _, values, err := 
adminconfig.Client.GetChildrenKVList(legacyMethodPrefix(resourceID, 
unpublished))
+       if err != nil {
+               return nil, err
+       }
+       methods := make([]config.Method, 0, len(values))
+       for _, value := range values {
+               var method config.Method
+               if err := commonyaml.UnmarshalYML([]byte(value), &method); err 
!= nil {
+                       return nil, fmt.Errorf("decode legacy method: %w", err)
+               }
+               methods = append(methods, method)
+       }
+       return methods, nil
+}
+
+// BizUpdateResourceAndMethods updates a legacy Resource and its Methods in one
+// etcd transaction. This keeps Method.ResourcePath aligned with the Resource
+// when a legacy client changes the route path.
+func BizUpdateResourceAndMethods(resource *config.Resource, methods 
[]config.Method, unpublished bool) error {
+       if resource == nil {
+               return errors.New("legacy resource is nil")
+       }
+       resourceID, err := normalizePositiveLegacyID(strconv.Itoa(resource.ID), 
ResourceID)
+       if err != nil {
+               return err
+       }
+       if adminconfig.Client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+       client := adminconfig.Client.GetRawClient()
+       if client == nil {
+               return errors.New("admin etcd client is unavailable")
+       }
+
+       storedResource := *resource
+       storedResource.Methods = nil
+       resourceData, err := commonyaml.MarshalYML(storedResource)
+       if err != nil {
+               return fmt.Errorf("encode legacy resource: %w", err)
+       }
+       operations := []clientv3.Op{clientv3.OpPut(
+               legacyResourceKey(resourceID, unpublished), 
string(resourceData),
+       )}
+       for index := range methods {
+               if methods[index].ID <= 0 {
+                       return fmt.Errorf("legacy method id must be positive, 
got %d", methods[index].ID)
+               }
+               methods[index].ResourcePath = resource.Path
+               methodData, err := commonyaml.MarshalYML(methods[index])
+               if err != nil {
+                       return fmt.Errorf("encode legacy method %d: %w", 
methods[index].ID, err)
+               }
+               operations = append(operations, clientv3.OpPut(
+                       legacyMethodKey(resourceID, 
strconv.Itoa(methods[index].ID), unpublished), string(methodData),
+               ))

Review Comment:
   During a Resource path change, these writes can overwrite a concurrent 
Method edit or restore a deleted Method because the controller fetched the 
Method bodies before the publisher reads its generation guard. Carry the 
revisions from the original Resource/Method reads into the transaction 
comparisons so stale path updates fail instead of overwriting newer state.



##########
admin/controller/configInfo/legacy_resource.go:
##########
@@ -0,0 +1,285 @@
+/*
+ * 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.
+ */
+
+package configInfo
+
+import (
+       "encoding/json"
+       "errors"
+       "net/http"
+       "strconv"
+       "strings"
+)
+
+import (
+       "github.com/gin-gonic/gin"
+)
+
+import (
+       adminconfig "github.com/apache/dubbo-go-pixiu/admin/config"
+       "github.com/apache/dubbo-go-pixiu/admin/logic"
+       commonyaml "github.com/apache/dubbo-go-pixiu/pkg/common/yaml"
+       "github.com/apache/dubbo-go-pixiu/pkg/config"
+)
+
+// These handlers preserve the Resource/Method Admin API for clients deployed
+// before AdminRouteBinding. They continue to read/write the legacy runtime
+// etcd keys, so old YAML and published records remain usable.
+func GetResourceList(c *gin.Context) {
+       resources, err := logic.BizGetResourceList(legacyUnpublished(c))
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       data, _ := json.Marshal(resources)
+       c.JSON(http.StatusOK, adminconfig.WithRet(string(data)))
+}
+
+func GetResourceDetail(c *gin.Context) {
+       detail, err := logic.BizGetResourceDetail(c.Query(logic.ResourceID), 
legacyUnpublished(c))
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       c.JSON(http.StatusOK, adminconfig.WithRet(detail))
+}
+
+func CreateResourceInfo(c *gin.Context) {
+       resource, err := decodeLegacyResource(c)
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       // Creation always assigns server-owned identities; positive IDs are 
only
+       // accepted by the logic layer when mirroring the same records to draft.
+       resource.ID = 0
+       for index := range resource.Methods {
+               resource.Methods[index].ID = 0
+       }
+       if legacyUnpublished(c) {
+               err = logic.BizSetResourceInfo(resource, true, true)
+       } else {
+               err = logic.BizSetResourceInfo(resource, true, false)
+               if err == nil {
+                       // Mirror the published records into the draft 
namespace with the
+                       // same Resource/Method IDs. Allocating a second set 
here would make
+                       // subsequent edits and publishes address a different 
route.
+                       err = logic.BizSetResourceInfo(resource, false, true)
+               }
+               if err == nil {
+                       resourceID := strconv.Itoa(resource.ID)
+                       for index := range resource.Methods {
+                               if err = logic.BizSetResourceMethod(resourceID, 
&resource.Methods[index], false, true); err != nil {
+                                       break
+                               }
+                       }
+               }
+       }
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       c.JSON(http.StatusOK, adminconfig.WithRet("Success"))
+}
+
+func ModifyResourceInfo(c *gin.Context) {
+       resource, err := decodeLegacyResource(c)
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       id := strings.TrimSpace(c.Query(logic.ResourceID))
+       if id != "" {
+               resource.ID, err = strconv.Atoi(id)
+               if err != nil {
+                       legacyError(c, err)
+                       return
+               }
+       }
+       unpublished := legacyUnpublished(c)
+       oldContent, err := 
logic.BizGetResourceDetail(strconv.Itoa(resource.ID), unpublished)
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       var old config.Resource
+       if err := commonyaml.UnmarshalYML([]byte(oldContent), &old); err != nil 
{
+               legacyError(c, err)
+               return
+       }
+       var updateErr error
+       if old.Path != resource.Path {
+               methods, err := 
logic.BizGetMethodList(strconv.Itoa(resource.ID), unpublished)
+               if err != nil {
+                       legacyError(c, err)
+                       return
+               }
+               updateErr = logic.BizUpdateResourceAndMethods(resource, 
methods, unpublished)
+       } else {
+               updateErr = logic.BizSetResourceInfo(resource, false, 
unpublished)
+       }
+       if updateErr != nil {
+               legacyError(c, updateErr)
+               return
+       }
+       c.JSON(http.StatusOK, adminconfig.WithRet("Success"))
+}
+
+func DeleteResourceInfo(c *gin.Context) {
+       id := c.Query(logic.ResourceID)
+       resourceID, err := strconv.Atoi(strings.TrimSpace(id))
+       if err != nil || resourceID <= 0 {
+               legacyError(c, errors.New("resourceId must be a positive 
integer"))
+               return
+       }
+       id = strconv.Itoa(resourceID)
+       unpublished := legacyUnpublished(c)
+       if unpublished {
+               published, err := logic.BizResourceExists(id, false)
+               if err != nil {
+                       legacyError(c, err)
+                       return
+               }
+               if published {
+                       legacyError(c, errors.New("the configuration has been 
published and cannot be deleted"))
+                       return
+               }
+       }
+       if err := logic.BizDeleteResourceInfo(id, unpublished); err != nil {
+               legacyError(c, err)
+               return
+       }
+       c.JSON(http.StatusOK, adminconfig.WithRet("Success"))
+}
+
+func GetMethodList(c *gin.Context) {
+       methods, err := logic.BizGetMethodList(c.Query(logic.ResourceID), 
legacyUnpublished(c))
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       data, _ := json.Marshal(methods)
+       c.JSON(http.StatusOK, adminconfig.WithRet(string(data)))
+}
+
+func GetMethodDetail(c *gin.Context) {
+       detail, err := logic.BizGetMethodDetail(c.Query(logic.ResourceID), 
c.Query(logic.MethodID), legacyUnpublished(c))
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       c.JSON(http.StatusOK, adminconfig.WithRet(detail))
+}
+
+func CreateMethodInfo(c *gin.Context) { saveLegacyMethod(c, true) }
+
+func ModifyMethodInfo(c *gin.Context) { saveLegacyMethod(c, false) }
+
+func saveLegacyMethod(c *gin.Context, create bool) {
+       var method config.Method
+       if err := commonyaml.UnmarshalYML([]byte(c.PostForm("content")), 
&method); err != nil {
+               legacyError(c, err)
+               return
+       }
+       resourceID := c.Query(logic.ResourceID)
+       resourceContent, err := logic.BizGetResourceDetail(resourceID, 
legacyUnpublished(c))
+       if err != nil {
+               legacyError(c, err)
+               return
+       }
+       var resource config.Resource
+       if err := commonyaml.UnmarshalYML([]byte(resourceContent), &resource); 
err != nil {
+               legacyError(c, err)
+               return
+       }
+       method.ResourcePath = resource.Path
+       if !create {
+               methodID, err := strconv.Atoi(c.Query(logic.MethodID))
+               if err != nil {
+                       legacyError(c, err)
+                       return
+               }
+               method.ID = methodID
+       } else {
+               method.ID = 0
+       }

Review Comment:
   The restored legacy update endpoint now requires the methodId query 
parameter even when the Method YAML contains its id. Before #1046, 
ModifyMethodInfo only overrode the decoded ID when methodId was supplied, and 
documented that query parameter as optional. Existing clients that send 
resourceId plus an id-bearing YAML body now fail on strconv.Atoi(""). Preserve 
the decoded Method.ID when the query parameter is absent.



##########
pkg/config/schema/builtin.go:
##########
@@ -72,128 +78,282 @@ func adminRouteBindingSchema() ObjectSchema {
                                },
                                UI: UIHints{Group: "entry", Order: 10},
                        },
-                       "target": {
+                       "backendRef": {
                                Type:     FieldTypeObject,
                                Required: true,
                                Properties: map[string]*FieldSchema{
-                                       "protocol": {
-                                               Type:    FieldTypeString,
-                                               Default: "dubbo",
-                                               Enum:    []any{"dubbo"},
-                                               UI:      UIHints{Component: 
"select", Order: 10},
-                                       },
-                                       "application": {
+                                       "type": {
                                                Type:        FieldTypeString,
-                                               Required:    true,
-                                               Description: "Dubbo 
applicationName",
-                                               UI:          UIHints{Component: 
"text", Order: 20},
-                                       },
-                                       "interface": {
-                                               Type:     FieldTypeString,
-                                               Required: true,
-                                               UI:       UIHints{Component: 
"text", Order: 30},
+                                               Default:     "registry",
+                                               Enum:        []any{"registry"},
+                                               Description: "Dubbo services 
are resolved from the registries configured on the listener.",
+                                               UI:          UIHints{Component: 
"text", Order: 10},
                                        },
-                                       "method": {
-                                               Type:     FieldTypeString,
-                                               Required: true,
-                                               UI:       UIHints{Component: 
"text", Order: 40},
-                                       },
-                                       "version": {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 50}},
-                                       "group":   {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 60}},
-                                       "cluster": {
+                                       "clusterName": {
                                                Type:        FieldTypeString,
-                                               Required:    true,
-                                               Description: "legacy 
integrationRequest.clusterName",
-                                               UI:          UIHints{Component: 
"text", Order: 70},
+                                               Description: "Preserved only 
when migrating legacy target.cluster to integrationRequest.clusterName.",
                                        },
                                },
-                               UI: UIHints{Group: "target", Order: 20},
+                               UI: UIHints{Group: "backend", Order: 20},
                        },
-                       "params": {
-                               Type:        FieldTypeArray,
-                               Default:     []any{},
-                               Description: "Ordered HTTP source to Dubbo 
argument mappings",
-                               Items: &FieldSchema{
-                                       Type: FieldTypeObject,
-                                       Properties: map[string]*FieldSchema{
-                                               "from": {
-                                                       Type:        
FieldTypeString,
-                                                       Required:    true,
-                                                       Pattern:     
`^(uri|queryStrings|headers|requestBody)\..+`,
-                                                       Description: "legacy 
mappingParams.name",
-                                               },
-                                               "to": {
-                                                       Type:        
FieldTypeInteger,
-                                                       Required:    true,
-                                                       Minimum:     
floatPointer(0),
-                                                       Description: 
"zero-based Dubbo argument index",
-                                               },
-                                               "type": {
-                                                       Type:        
FieldTypeString,
-                                                       Required:    true,
-                                                       Enum:        
supportedDubboParamTypeEnum(),
-                                                       Description: "legacy 
mapType and parameterTypes entry",
+                       "serviceSelection": {
+                               Type:     FieldTypeObject,
+                               Required: true,
+                               Properties: map[string]*FieldSchema{
+                                       "application": {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 10}},
+                                       "interface":   {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 20}},
+                                       "group":       {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 30}},
+                                       "version":     {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 40}},
+                               },
+                               UI: UIHints{Group: "service", Order: 30},
+                       },
+                       "invocation": {
+                               Type:     FieldTypeObject,
+                               Required: true,
+                               Properties: map[string]*FieldSchema{
+                                       "method":  {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 10}},
+                                       "timeout": {Type: FieldTypeString, 
Default: "1s", Description: "Positive Go duration string", UI: 
UIHints{Component: "text", Order: 20}},
+                                       "parameters": {
+                                               Type:        FieldTypeArray,
+                                               Default:     []any{},
+                                               Description: "Ordered HTTP 
source to Dubbo argument mappings",
+                                               Items: &FieldSchema{
+                                                       Type: FieldTypeObject,
+                                                       Properties: 
map[string]*FieldSchema{
+                                                               "from": {
+                                                                       Type:   
     FieldTypeString,
+                                                                       
Required:    true,
+                                                                       
Pattern:     `^(uri|queryStrings|headers|requestBody)\..+`,
+                                                                       
Description: "legacy mappingParams.name",
+                                                               },
+                                                               "to": {
+                                                                       Type:   
     FieldTypeInteger,
+                                                                       
Required:    true,
+                                                                       
Minimum:     floatPointer(0),
+                                                                       
Description: "zero-based Dubbo argument index",
+                                                               },
+                                                               "type": {
+                                                                       Type:   
     FieldTypeString,
+                                                                       
Required:    true,
+                                                                       Enum:   
     supportedDubboParamTypeEnum(),
+                                                                       
Description: "legacy mapType and parameterTypes entry",
+                                                               },
+                                                       },
                                                },
+                                               UI: UIHints{Component: 
"parameter-binding-table", Group: "invocation", Order: 30},
                                        },
                                },
-                               UI: UIHints{Component: 
"parameter-binding-table", Group: "params", Order: 30},
+                               UI: UIHints{Group: "invocation", Order: 40},
                        },
                        "enabled": {
                                Type:        FieldTypeBoolean,
                                Default:     true,
                                Description: "Whether Pixiu accepts requests 
for the published route",
                                UI:          UIHints{Component: "switch", 
Group: "lifecycle", Order: 10},
                        },
-                       "extensions": {
-                               Type:    FieldTypeObject,
-                               Default: map[string]any{},
-                               UI:      UIHints{Component: "extension-fields", 
Group: "advanced", Order: 50, Advanced: true},
-                       },
                },
        }
 }
 
-func validateAdminRouteBinding(object AdminObject) []ValidationIssue {
-       params, ok := object.Spec["params"].([]any)
-       if !ok {
+// migrateLegacyRouteBindingSpec converts the target/params shape emitted by
+// PR #1046 to the separated backend/service/invocation contract. It only
+// migrates the known legacy fields and rejects mixed or unknown input rather
+// than silently discarding configuration.
+func migrateLegacyRouteBindingSpec(object *AdminObject) []ValidationIssue {
+       if issues := removeEmptyLegacyExtensions(object.Spec); len(issues) > 0 {
+               return issues
+       }
+       if !hasLegacyRouteBindingFields(object.Spec) {
                return nil
        }
+       target, issues := validateLegacyRouteBindingTarget(object.Spec)
+       if len(issues) > 0 {
+               return issues
+       }
+       applyLegacyRouteBindingMigration(object.Spec, target)
+       return nil
+}
+
+func removeEmptyLegacyExtensions(spec map[string]any) []ValidationIssue {
+       extensions, exists := spec["extensions"]
+       if !exists {
+               return nil
+       }
+       values, ok := extensions.(map[string]any)
+       if !ok || len(values) != 0 {
+               return []ValidationIssue{issue("spec.extensions", 
"unsupported", "route extensions are not supported; remove this field")}
+       }
+       delete(spec, "extensions")
+       return nil
+}
+
+func hasLegacyRouteBindingFields(spec map[string]any) bool {
+       _, hasTarget := spec["target"]
+       _, hasParams := spec["params"]
+       return hasTarget || hasParams
+}
+
+func validateLegacyRouteBindingTarget(spec map[string]any) (map[string]any, 
[]ValidationIssue) {
+       for _, field := range []string{"backendRef", "serviceSelection", 
"invocation"} {
+               if _, exists := spec[field]; exists {
+                       return nil, []ValidationIssue{issue("spec."+field, 
"mixed_model", "cannot combine the legacy target/params fields with the 
separated route model")}
+               }
+       }
+       target, ok := spec["target"].(map[string]any)
+       if _, hasTarget := spec["target"]; !hasTarget || !ok {
+               return nil, []ValidationIssue{issue("spec.target", "migration", 
"legacy target must be an object")}
+       }
+       issues := validateLegacyTargetFields(target)
+       return target, issues
+}
 
+func validateLegacyTargetFields(target map[string]any) []ValidationIssue {
+       issues := make([]ValidationIssue, 0)
+       allowedTargetFields := map[string]bool{"protocol": true, "application": 
true, "interface": true, "method": true, "version": true, "group": true, 
"cluster": true}
+       for key := range target {
+               if !allowedTargetFields[key] {
+                       issues = append(issues, issue("spec.target."+key, 
"migration", "legacy field has no AdminRouteBinding migration"))
+               }
+       }
+       if protocol, _ := target["protocol"].(string); protocol != "" && 
protocol != "dubbo" {

Review Comment:
   A failed string assertion is treated as an omitted protocol, so legacy input 
such as `target.protocol: 123` or `target.protocol: false` is silently 
rewritten to Dubbo. Reject non-string protocol values here, before migration 
removes the field and prevents normal schema validation from catching them.



##########
pkg/config/schema/builtin.go:
##########
@@ -72,128 +78,282 @@ func adminRouteBindingSchema() ObjectSchema {
                                },
                                UI: UIHints{Group: "entry", Order: 10},
                        },
-                       "target": {
+                       "backendRef": {
                                Type:     FieldTypeObject,
                                Required: true,
                                Properties: map[string]*FieldSchema{
-                                       "protocol": {
-                                               Type:    FieldTypeString,
-                                               Default: "dubbo",
-                                               Enum:    []any{"dubbo"},
-                                               UI:      UIHints{Component: 
"select", Order: 10},
-                                       },
-                                       "application": {
+                                       "type": {
                                                Type:        FieldTypeString,
-                                               Required:    true,
-                                               Description: "Dubbo 
applicationName",
-                                               UI:          UIHints{Component: 
"text", Order: 20},
-                                       },
-                                       "interface": {
-                                               Type:     FieldTypeString,
-                                               Required: true,
-                                               UI:       UIHints{Component: 
"text", Order: 30},
+                                               Default:     "registry",
+                                               Enum:        []any{"registry"},
+                                               Description: "Dubbo services 
are resolved from the registries configured on the listener.",
+                                               UI:          UIHints{Component: 
"text", Order: 10},
                                        },
-                                       "method": {
-                                               Type:     FieldTypeString,
-                                               Required: true,
-                                               UI:       UIHints{Component: 
"text", Order: 40},
-                                       },
-                                       "version": {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 50}},
-                                       "group":   {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 60}},
-                                       "cluster": {
+                                       "clusterName": {
                                                Type:        FieldTypeString,
-                                               Required:    true,
-                                               Description: "legacy 
integrationRequest.clusterName",
-                                               UI:          UIHints{Component: 
"text", Order: 70},
+                                               Description: "Preserved only 
when migrating legacy target.cluster to integrationRequest.clusterName.",
                                        },
                                },
-                               UI: UIHints{Group: "target", Order: 20},
+                               UI: UIHints{Group: "backend", Order: 20},
                        },
-                       "params": {
-                               Type:        FieldTypeArray,
-                               Default:     []any{},
-                               Description: "Ordered HTTP source to Dubbo 
argument mappings",
-                               Items: &FieldSchema{
-                                       Type: FieldTypeObject,
-                                       Properties: map[string]*FieldSchema{
-                                               "from": {
-                                                       Type:        
FieldTypeString,
-                                                       Required:    true,
-                                                       Pattern:     
`^(uri|queryStrings|headers|requestBody)\..+`,
-                                                       Description: "legacy 
mappingParams.name",
-                                               },
-                                               "to": {
-                                                       Type:        
FieldTypeInteger,
-                                                       Required:    true,
-                                                       Minimum:     
floatPointer(0),
-                                                       Description: 
"zero-based Dubbo argument index",
-                                               },
-                                               "type": {
-                                                       Type:        
FieldTypeString,
-                                                       Required:    true,
-                                                       Enum:        
supportedDubboParamTypeEnum(),
-                                                       Description: "legacy 
mapType and parameterTypes entry",
+                       "serviceSelection": {
+                               Type:     FieldTypeObject,
+                               Required: true,
+                               Properties: map[string]*FieldSchema{
+                                       "application": {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 10}},
+                                       "interface":   {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 20}},
+                                       "group":       {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 30}},
+                                       "version":     {Type: FieldTypeString, 
Default: "", UI: UIHints{Component: "text", Order: 40}},
+                               },
+                               UI: UIHints{Group: "service", Order: 30},
+                       },
+                       "invocation": {
+                               Type:     FieldTypeObject,
+                               Required: true,
+                               Properties: map[string]*FieldSchema{
+                                       "method":  {Type: FieldTypeString, 
Required: true, UI: UIHints{Component: "text", Order: 10}},
+                                       "timeout": {Type: FieldTypeString, 
Default: "1s", Description: "Positive Go duration string", UI: 
UIHints{Component: "text", Order: 20}},
+                                       "parameters": {
+                                               Type:        FieldTypeArray,
+                                               Default:     []any{},
+                                               Description: "Ordered HTTP 
source to Dubbo argument mappings",
+                                               Items: &FieldSchema{
+                                                       Type: FieldTypeObject,
+                                                       Properties: 
map[string]*FieldSchema{
+                                                               "from": {
+                                                                       Type:   
     FieldTypeString,
+                                                                       
Required:    true,
+                                                                       
Pattern:     `^(uri|queryStrings|headers|requestBody)\..+`,
+                                                                       
Description: "legacy mappingParams.name",
+                                                               },
+                                                               "to": {
+                                                                       Type:   
     FieldTypeInteger,
+                                                                       
Required:    true,
+                                                                       
Minimum:     floatPointer(0),
+                                                                       
Description: "zero-based Dubbo argument index",
+                                                               },
+                                                               "type": {
+                                                                       Type:   
     FieldTypeString,
+                                                                       
Required:    true,
+                                                                       Enum:   
     supportedDubboParamTypeEnum(),
+                                                                       
Description: "legacy mapType and parameterTypes entry",
+                                                               },
+                                                       },
                                                },
+                                               UI: UIHints{Component: 
"parameter-binding-table", Group: "invocation", Order: 30},
                                        },
                                },
-                               UI: UIHints{Component: 
"parameter-binding-table", Group: "params", Order: 30},
+                               UI: UIHints{Group: "invocation", Order: 40},
                        },
                        "enabled": {
                                Type:        FieldTypeBoolean,
                                Default:     true,
                                Description: "Whether Pixiu accepts requests 
for the published route",
                                UI:          UIHints{Component: "switch", 
Group: "lifecycle", Order: 10},
                        },
-                       "extensions": {
-                               Type:    FieldTypeObject,
-                               Default: map[string]any{},
-                               UI:      UIHints{Component: "extension-fields", 
Group: "advanced", Order: 50, Advanced: true},
-                       },
                },
        }
 }
 
-func validateAdminRouteBinding(object AdminObject) []ValidationIssue {
-       params, ok := object.Spec["params"].([]any)
-       if !ok {
+// migrateLegacyRouteBindingSpec converts the target/params shape emitted by
+// PR #1046 to the separated backend/service/invocation contract. It only
+// migrates the known legacy fields and rejects mixed or unknown input rather
+// than silently discarding configuration.
+func migrateLegacyRouteBindingSpec(object *AdminObject) []ValidationIssue {
+       if issues := removeEmptyLegacyExtensions(object.Spec); len(issues) > 0 {
+               return issues
+       }
+       if !hasLegacyRouteBindingFields(object.Spec) {
                return nil
        }
+       target, issues := validateLegacyRouteBindingTarget(object.Spec)
+       if len(issues) > 0 {
+               return issues
+       }
+       applyLegacyRouteBindingMigration(object.Spec, target)
+       return nil
+}
+
+func removeEmptyLegacyExtensions(spec map[string]any) []ValidationIssue {
+       extensions, exists := spec["extensions"]
+       if !exists {
+               return nil
+       }
+       values, ok := extensions.(map[string]any)
+       if !ok || len(values) != 0 {
+               return []ValidationIssue{issue("spec.extensions", 
"unsupported", "route extensions are not supported; remove this field")}
+       }
+       delete(spec, "extensions")
+       return nil
+}
+
+func hasLegacyRouteBindingFields(spec map[string]any) bool {
+       _, hasTarget := spec["target"]
+       _, hasParams := spec["params"]
+       return hasTarget || hasParams
+}
+
+func validateLegacyRouteBindingTarget(spec map[string]any) (map[string]any, 
[]ValidationIssue) {
+       for _, field := range []string{"backendRef", "serviceSelection", 
"invocation"} {
+               if _, exists := spec[field]; exists {
+                       return nil, []ValidationIssue{issue("spec."+field, 
"mixed_model", "cannot combine the legacy target/params fields with the 
separated route model")}
+               }
+       }
+       target, ok := spec["target"].(map[string]any)
+       if _, hasTarget := spec["target"]; !hasTarget || !ok {
+               return nil, []ValidationIssue{issue("spec.target", "migration", 
"legacy target must be an object")}
+       }
+       issues := validateLegacyTargetFields(target)
+       return target, issues
+}
 
+func validateLegacyTargetFields(target map[string]any) []ValidationIssue {
+       issues := make([]ValidationIssue, 0)
+       allowedTargetFields := map[string]bool{"protocol": true, "application": 
true, "interface": true, "method": true, "version": true, "group": true, 
"cluster": true}
+       for key := range target {
+               if !allowedTargetFields[key] {
+                       issues = append(issues, issue("spec.target."+key, 
"migration", "legacy field has no AdminRouteBinding migration"))
+               }
+       }
+       if protocol, _ := target["protocol"].(string); protocol != "" && 
protocol != "dubbo" {
+               issues = append(issues, issue("spec.target.protocol", 
"migration", "only the legacy dubbo protocol can be migrated"))
+       }
+       return issues
+}
+
+func applyLegacyRouteBindingMigration(spec, target map[string]any) {
+       backendRef := map[string]any{"type": "registry"}
+       if clusterName, exists := target["cluster"]; exists {
+               backendRef["clusterName"] = clusterName
+       }
+       spec["backendRef"] = backendRef
+       spec["serviceSelection"] = map[string]any{
+               "application": target["application"],
+               "interface":   target["interface"],
+               "group":       target["group"],
+               "version":     target["version"],
+       }
+       parameters, exists := spec["params"]
+       if !exists {
+               parameters = []any{}
+       }
+       spec["invocation"] = map[string]any{
+               "method":     target["method"],
+               "timeout":    "1s",
+               "parameters": parameters,
+       }
+       delete(spec, "target")
+       delete(spec, "params")
+}
+
+func validateAdminRouteBinding(object AdminObject) []ValidationIssue {
+       issues := make([]ValidationIssue, 0)
+       entry, _ := object.Spec["entry"].(map[string]any)
+       path, _ := entry["path"].(string)
+       service, _ := object.Spec["serviceSelection"].(map[string]any)
+       invocation, _ := object.Spec["invocation"].(map[string]any)
+
+       issues = append(issues, validateRouteBindingService(service, 
invocation)...)
+       if params, ok := invocation["parameters"].([]any); ok {
+               issues = append(issues, validateRouteBindingParameters(params, 
routePathParameters(path))...)
+       }
+       return issues
+}
+
+func validateRouteBindingService(service, invocation map[string]any) 
[]ValidationIssue {
+       issues := make([]ValidationIssue, 0)
+       for _, field := range []string{"application", "interface"} {
+               value, _ := service[field].(string)
+               if strings.TrimSpace(value) == "" {
+                       issues = append(issues, 
issue("spec.serviceSelection."+field, "required", "must not be empty"))
+               }
+       }
+       method, _ := invocation["method"].(string)
+       if strings.TrimSpace(method) == "" {
+               issues = append(issues, issue("spec.invocation.method", 
"required", "must not be empty"))
+       }
+       timeout, _ := invocation["timeout"].(string)
+       duration, err := time.ParseDuration(timeout)
+       if err != nil || duration <= 0 {
+               issues = append(issues, issue("spec.invocation.timeout", 
"duration", "must be a positive duration such as 500ms or 2s"))
+       }
+       return issues
+}
+
+func validateRouteBindingParameters(params []any, pathParams 
map[string]struct{}) []ValidationIssue {
        issues := make([]ValidationIssue, 0)
        seenIndexes := make(map[int]int, len(params))
+       usedPathParams := make(map[string]int)
        for index, rawParam := range params {
                param, ok := rawParam.(map[string]any)
                if !ok {
                        continue
                }
-               toNumber, ok := numericValue(param["to"])
-               if !ok {
-                       continue
-               }
-               to := int(toNumber)
-               if previous, exists := seenIndexes[to]; exists {
-                       issues = append(issues, issue(
-                               fmt.Sprintf("spec.params[%d].to", index),
-                               "duplicate",
-                               fmt.Sprintf("duplicates params[%d] argument 
index %d", previous, to),
-                       ))
-               } else {
-                       seenIndexes[to] = index
-               }
+               issues = append(issues, validateRouteBindingParameter(index, 
param, pathParams, seenIndexes, usedPathParams)...)
+       }
+       issues = append(issues, validatePathParameterMappings(pathParams, 
usedPathParams)...)
+       issues = append(issues, validateContiguousParameterIndexes(params, 
seenIndexes)...)
+       return issues
+}
 
-               if paramType, ok := param["type"].(string); ok && 
!isSupportedParamType(paramType) {
-                       issues = append(issues, issue(
-                               fmt.Sprintf("spec.params[%d].type", index),
-                               "unsupported",
-                               fmt.Sprintf("unsupported scalar Dubbo map type 
%q", paramType),
-                       ))
+func validateRouteBindingParameter(index int, param map[string]any, pathParams 
map[string]struct{}, seenIndexes map[int]int, usedPathParams map[string]int) 
[]ValidationIssue {
+       issues := make([]ValidationIssue, 0)
+       toNumber, ok := numericValue(param["to"])
+       if !ok {
+               return issues
+       }
+       to := int(toNumber)
+       if previous, exists := seenIndexes[to]; exists {
+               issues = append(issues, issue(
+                       fmt.Sprintf("spec.invocation.parameters[%d].to", index),
+                       "duplicate",
+                       fmt.Sprintf("duplicates params[%d] argument index %d", 
previous, to),
+               ))
+       } else {
+               seenIndexes[to] = index
+       }
+
+       if paramType, ok := param["type"].(string); ok && 
!isSupportedParamType(paramType) {
+               issues = append(issues, issue(
+                       fmt.Sprintf("spec.invocation.parameters[%d].type", 
index),
+                       "unsupported",
+                       fmt.Sprintf("unsupported scalar Dubbo map type %q", 
paramType),
+               ))
+       }
+       if source, ok := param["from"].(string); ok && 
strings.HasPrefix(source, "uri.") {
+               issues = append(issues, validatePathParameterSource(index, 
source, pathParams, usedPathParams)...)
+       }
+       return issues
+}
+
+func validatePathParameterSource(index int, source string, pathParams 
map[string]struct{}, usedPathParams map[string]int) []ValidationIssue {
+       name := strings.TrimPrefix(source, "uri.")
+       if _, exists := pathParams[name]; !exists {
+               return 
[]ValidationIssue{issue(fmt.Sprintf("spec.invocation.parameters[%d].from", 
index), "path_mismatch", fmt.Sprintf("URI parameter %q does not appear in 
spec.entry.path", name))}

Review Comment:
   `/users/:id.json` with `from: uri.id.json` passes validation, but every 
invocation fails because the runtime looks up `id` while the router captures 
`id.json`. Reject dotted URI parameter names during validation and change the 
new acceptance test, or explicitly support full URI keys in the runtime reader.



##########
admin/web/src/features/config/RouteBindingEditor.tsx:
##########
@@ -527,6 +556,72 @@ export function RouteBindingEditor({
     }
   }
 
+  const loadHistory = async () => {
+    if (mode === 'create' || !object.metadata.name) return
+    setHistoryLoading(true)
+    setNotice(null)
+    try {
+      setHistoryEntries(await routeBindingApi.history(object.metadata.name))
+    } catch (error: unknown) {
+      setNotice({ tone: 'error', text: errorMessage(error, tx('加载历史失败')) })
+    } finally {
+      setHistoryLoading(false)
+    }
+  }
+
+  const rollbackToRevision = async (historyRevision: string) => {
+    if (mode !== 'edit' || dirty || yamlError || !schema) return
+    const selected = historyEntries.find((entry) => entry.revision === 
historyRevision)
+    if (!selected) return
+    let prompt: string
+    if (selected.object) {
+      prompt = isEnglish
+        ? `Publish revision ${historyRevision} again?`
+        : `确认重新发布历史版本 ${historyRevision}?`
+    } else {
+      prompt = isEnglish
+        ? 'This snapshot deletes the route. Continue?'
+        : '该历史快照会删除此路由,确认继续?'
+    }
+    if (!window.confirm(prompt)) return
+    setBusy('publish')
+    setNotice(null)
+    try {
+      const name = object.metadata.name
+      const currentStatus = await routeBindingApi.status(name)
+      await routeBindingApi.rollback(name, historyRevision, 
currentStatus.draftRevision)

Review Comment:
   Fetching the latest draft revision immediately before rollback defeats the 
stale-editor check. If another operator saves changes after this editor was 
opened, those unseen changes are silently overwritten (or deleted for a 
deletion snapshot) because rollback receives their revision rather than the 
revision the user reviewed. Pass the editor's captured revision, as 
save/publish already do, so concurrent changes return a conflict.



-- 
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