Aias00 opened a new issue, #7804: URL: https://github.com/apache/shenyu/issues/7804
### Is there an existing issue for this? - [x] I searched existing issues for Discovery upstream protocol/registration problems and did not find this malformed-HTTP-protocol case. ### Current Behavior The Admin Discovery/Proxy Selector registration path accepts a bare HTTP protocol value such as `"protocol": "http"`, but the divide gateway's domain builder concatenates that string directly with the upstream address. This produces an invalid target rather than a clear configuration error: ```text http + 127.0.0.1:8080 -> http127.0.0.1:8080 http:// + 127.0.0.1:8080 -> http://127.0.0.1:8080 ``` In a local cluster this resulted in `UnknownHostException` for a hostname starting with `http` followed by the upstream IP. Following failed health updates, requests also reported `-119` / no healthy upstream. This was initially encountered while configuring external HTTP services. A bare protocol value was my configuration mistake; the product issue is that the API accepts it without normalization or a useful validation error. It is not a claim that the existing `selector.handle` format has been removed. ### Expected Behavior Define and enforce one protocol contract for HTTP divide Discovery upstreams: - Normalize supported scheme names to a URL prefix, or reject an unsupported format when saving configuration. - Return a clear field-level error before persisting/publishing an invalid target. - Use consistent examples in DTO comments, registration helpers, tests and documentation. Also make clear that Discovery upstream `status` is an integer (`0=healthy`, `1=unhealthy`), whereas the legacy divide `CommonUpstream.status` field is boolean. `status: 1` is valid but means unhealthy; this issue does not request treating it as enabled. ### Steps To Reproduce 1. Run Admin and a divide gateway using WebSocket sync. Use any reachable HTTP upstream, e.g. an echo server. 2. Create a divide selector and rule for `/test/**` and bind it through authenticated `POST /proxy-selector/binding`, with a local Discovery and an upstream similar to: ```json { "selectorId": "<existing-divide-selector-id>", "name": "test", "pluginName": "divide", "type": "http", "forwardPort": 0, "props": "{}", "namespaceId": "<namespace-id>", "discovery": {"discoveryType": "local", "serverList": "", "props": "{}"}, "discoveryUpstreams": [{ "id": "test-upstream", "protocol": "http", "url": "<reachable-upstream-host>:8080", "status": 0, "weight": 100, "props": "{}", "namespaceId": "<namespace-id>" }] } ``` 3. The API accepts the registration. Call the matching route and inspect the invalid target/host failure. 4. Change `protocol` to `"http://"`; the same service can be proxied successfully. The domain-construction part also reproduces independently against the built gateway libraries: ```java Upstream.builder().protocol("http").url("127.0.0.1:8080") .weight(100).status(true).build().buildDomain(); // http127.0.0.1:8080 ``` ### Environment - ShenYu `2.7.2-SNAPSHOT`, master `04f7c2e8b7d282f14510157a9ab0bfaab538ecac` - Java 17, ARM64 Docker deployment - Two Admin nodes sharing MySQL, two divide gateways using WebSocket sync ### Code evidence - [Upstream.buildDomain()](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java#L476-L481) defaults a blank protocol to `http://`, but directly concatenates a nonblank protocol without adding or validating `://`. - [DiscoveryUpstreamDTO](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/DiscoveryUpstreamDTO.java#L57-L85) does not constrain the protocol format; status is only `@NotNull`. - [ProxySelectorAddDTO.DiscoveryUpstream](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ProxySelectorAddDTO.java#L440-L478) also exposes a protocol string without a scheme-format contract. - [SelectorUtilTest](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-admin/src/test/java/org/apache/shenyu/admin/utils/SelectorUtilTest.java#L40-L56) uses a bare `http` value in a divide upstream example, while registration helpers use `http://`. A regression test should exercise the Admin-to-gateway contract for both bare schemes and URL prefixes, instead of testing JSON deserialization alone. -- 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]
