Aias00 opened a new pull request, #3538:
URL: https://github.com/apache/dubbo-go/pull/3538
## What
`MetadataServiceV2.GetMetadataInfo` nil-dereferences the result of
`delegate.GetMetadataInfo`, which returns `(nil, nil)` for an unknown/empty
revision. The `MetadataServiceV2Handler` is exported over Triple, so this
endpoint is remotely reachable.
## Why
```go
// metadata/metadata_service.go
func (mts *DefaultMetadataService) GetMetadataInfo(revision string)
(*info.MetadataInfo, error) {
if revision == "" { return nil, nil }
...
for _, metadataInfo := range mts.metadataMap {
if metadataInfo.Revision == revision { return metadataInfo, nil }
}
return nil, nil // unknown revision
}
func (mtsV2 *MetadataServiceV2) GetMetadataInfo(...)
(*tripleapi.MetadataInfoV2, error) {
metadataInfo, err := mtsV2.delegate.GetMetadataInfo(req.GetRevision())
if err != nil { return nil, err }
return &tripleapi.MetadataInfoV2{
App: metadataInfo.App, // nil deref
Version: metadataInfo.Revision,
Services: convertV2(metadataInfo.GetServices()),
Tag: metadataInfo.Tag,
}, err
}
```
A `getMetadataInfo` triple call with a revision the provider does not have
locally (not-yet-published, stale, wrong revision) → `metadataInfo.App`
nil-pointer panic → provider-side goroutine crash.
## Fix
```go
if metadataInfo == nil {
return nil, perrors.Errorf("metadata info not found for revision=%s",
req.GetRevision())
}
```
## Tests
Added `TestMetadataServiceV2GetMetadataInfoNilNoPanic`: a
`DefaultMetadataService` with an empty `metadataMap` → `GetMetadataInfo`
returns `(nil, nil)` for an unknown revision → asserts the V2 method returns an
error (no panic). `metadata` package passes under `-race`.
Fixes #3537
--
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]