Condition router v3.0 swaps enabled and force flags
Environment
- dubbo-go branch:
develop - affected code:
cluster/router/condition/generateConditionsRoute - config center: ZooKeeper
Description
The v3.0 condition-router parser assigns the two boolean fields in reverse order:
force, enable := *routerConfig.Enabled, *routerConfig.Force
As a result, a normal rule with enabled: true and force: false is interpreted as enable=false and force=true. DynamicRouter.Route then bypasses the condition router and returns the original invoker list.
The v3.1 parser is not affected because generateMultiConditionRoute reads and returns the fields in the correct order.
Reproduction
Store the following service-level rule in the config center:
configVersion: v3.0
priority: 1
enabled: true
force: false
runtime: true
key: org.apache.dubbo.quickstart.Greeter:1.0.0:demo
scope: service
conditions:
- method=SayHello => application=router-rule-e2e-condition-provider-hangzhou
Use two providers whose final consumer-side invoker URLs contain different application values. Calls continue to select both providers because the v3.0 router is treated as disabled.
Changing the same rule to v3.1 enters the separate multi-destination parser and routes normally.
Expected behavior
enabledcontrols whether the router executes.forcecontrols whether an empty routing result falls back to the original invokers.- Updating the same config-center node from v3.1 to v3.0 should replace the router state and apply the v3.0 condition immediately.
Proposed fix
Assign the fields in their declared order and add regression coverage for the asymmetric enabled: true / force: false combination, including a v3.1-to-v3.0 runtime update.
close via #3658