You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Alanxtl (via GitHub)" <gi...@apache.org> on 2026/06/01 10:04:17 UTC
[I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Alanxtl opened a new issue, #3359:
URL: https://github.com/apache/dubbo-go/issues/3359
## Title
REST application-level service discovery requires importing Dubbo protocol to fetch metadata
## Problem
A REST consumer using application-level service discovery fails unless it also imports the Dubbo protocol extension:
```go
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
```
Without this import, the consumer panics:
```text
panic: protocol for [dubbo] is not existing
```
This is surprising because the user-facing service protocol is REST. The Dubbo protocol is only used internally by the service discovery path to call `org.apache.dubbo.metadata.MetadataService`.
## Minimal Reproduction
There is currently no ready-made REST service-discovery sample in the repository, so this was reproduced with a small local REST provider/consumer sample.
### 1. Shared REST mapping
Create a REST service with one method:
- interface: `org.apache.dubbo.samples.rest.GreetingService`
- method: `GetGreeting`
- REST path: `POST /api/v1/users/{userID}/greeting`
- args:
- arg 0 -> path param `userID`
- arg 1 -> query param `name`
- arg 2 -> header `X-Trace-ID`
- arg 3 -> JSON body
Both provider and consumer install the same REST method config through:
```go
restconfig.SetRestProviderServiceConfigMap(...)
restconfig.SetRestConsumerServiceConfigMap(...)
```
### 2. Provider setup
The provider is configured as a REST service and uses application-level registration:
```go
ins, err := dubbo.NewInstance(
dubbo.WithName("dubbo_rest_basic_server"),
dubbo.WithProtocol(
protocol.WithREST(),
protocol.WithIp("127.0.0.1"),
protocol.WithPort(20080),
),
dubbo.WithRegistry(
registry.WithZookeeper(),
registry.WithAddress("127.0.0.1:2181"),
registry.WithoutUseAsConfigCenter(),
registry.WithRegisterService(),
),
)
```
Then register the REST service:
```go
srv, _ := ins.NewServer()
err = srv.RegisterService(
&GreetingProvider{},
dubboserver.WithInterface("org.apache.dubbo.samples.rest.GreetingService"),
)
err = srv.Serve()
```
Required provider imports include REST protocol, registry protocol, service discovery, metadata mapping/report, and ZooKeeper registry.
### 3. Consumer setup that fails
The consumer also uses application-level service discovery:
```go
ins, err := dubbo.NewInstance(
dubbo.WithName("dubbo_rest_basic_client"),
dubbo.WithRegistry(
registry.WithZookeeper(),
registry.WithAddress("127.0.0.1:2181"),
registry.WithoutUseAsConfigCenter(),
registry.WithRegisterService(),
),
)
cli, err := ins.NewClient(client.WithClientNoCheck())
conn, err := cli.Dial(
"org.apache.dubbo.samples.rest.GreetingService",
client.WithProtocol(constant.RESTProtocol),
)
```
The consumer imports REST protocol and service discovery related packages, but intentionally does **not** import Dubbo protocol:
```go
_ "dubbo.apache.org/dubbo-go/v3/protocol/rest"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery"
_ "dubbo.apache.org/dubbo-go/v3/registry/directory"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper"
```
Run:
```bash
go run ./server
go run ./client
```
The consumer fails with:
```text
panic: protocol for [dubbo] is not existing
```
### 4. Workaround
Adding this import to the REST consumer fixes the issue:
```go
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
```
After that, the REST call succeeds. The consumer discovers the provider application, fetches metadata through:
```text
dubbo://127.0.0.1:<metadata-port>/org.apache.dubbo.metadata.MetadataService
```
and reconstructs a REST provider URL like:
```text
rest://127.0.0.1:20080/org.apache.dubbo.samples.rest.GreetingService
```
## Expected Behavior
A REST consumer should not need to manually import Dubbo protocol just because it uses application-level service discovery.
If the metadata service internally uses Dubbo protocol, that dependency should be hidden by the service discovery / metadata module, or the error should clearly explain the required import.
## Actual Behavior
The REST consumer fails at runtime because service discovery tries to call the metadata service through `dubbo://...`, but the Dubbo protocol extension is not registered.
## Why This Matters
This leaks an internal metadata transport detail into user code. From the user perspective, the configured service protocol is REST, the registry is ZooKeeper/Nacos, and the registry type is application-level service discovery. Requiring a Dubbo protocol import is non-obvious and easy to miss.
## Suggested Fix
One of the following would improve the behavior:
1. service discovery automatically registers the protocol needed for metadata service calls;
2. provide a documented import bundle for application-level service discovery dependencies;
3. return a clearer error such as: `metadata service uses dubbo protocol, please import dubbo.apache.org/dubbo-go/v3/protocol/dubbo`.
--
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: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl closed issue #3359: [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata
URL: https://github.com/apache/dubbo-go/issues/3359
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "wlgusqkr (via GitHub)" <gi...@apache.org>.
wlgusqkr commented on issue #3359:
URL: https://github.com/apache/dubbo-go/issues/3359#issuecomment-4601361262
@Alanxtl Could you please take a look when you have time?
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on issue #3359:
URL: https://github.com/apache/dubbo-go/issues/3359#issuecomment-4591752879
> Hi, I'd like to work on this. Could it be assigned to me? Thanks!
sure
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on issue #3359:
URL: https://github.com/apache/dubbo-go/issues/3359#issuecomment-4608837917
Sorry, I took another look and realized this is not actually a bug in the way I originally described.
The metadata service protocol is recorded in the service instance metadata, and the registry itself does not need to understand or be compatible with the metadata RPC protocol. The consumer just needs the corresponding protocol capability when it calls the provider metadata service.
So this is more about sample/import setup than a framework bug. I’ll close this issue and the related PR. Thanks for looking into it and sorry for the confusion.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "wlgusqkr (via GitHub)" <gi...@apache.org>.
wlgusqkr commented on issue #3359:
URL: https://github.com/apache/dubbo-go/issues/3359#issuecomment-4591733155
Hi, I'd like to work on this. Could it be assigned to me? Thanks!
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] REST application-level service discovery requires importing Dubbo protocol to fetch metadata [dubbo-go]
Posted by "wlgusqkr (via GitHub)" <gi...@apache.org>.
wlgusqkr commented on issue #3359:
URL: https://github.com/apache/dubbo-go/issues/3359#issuecomment-4608878052
Thanks for the update! No need to apologize at all. I'm just glad to hear it's resolved. Have a great day
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org