@@ -349,37 +349,20 @@ func buildServiceMethodSummaries(metadataList []*meshresource.ServiceProviderMet
349349
350350func buildServiceMethodCandidates (metadataList []* meshresource.ServiceProviderMetadataResource ) []* serviceMethodCandidate {
351351 candidateByKey := make (map [string ]* serviceMethodCandidate )
352- structuredMethodNames := make (map [string ]struct {})
353- fallbackMethodNames := make (map [string ]struct {})
354352
355353 for _ , metadata := range metadataList {
354+ if metadata == nil || metadata .Spec == nil {
355+ continue
356+ }
356357 for _ , method := range metadata .Spec .Methods {
357358 candidate , ok := newStructuredServiceMethodCandidate (method )
358359 if ! ok {
359360 continue
360361 }
361362 candidateByKey [serviceMethodKey (candidate .detail .MethodName , candidate .signature )] = candidate
362- structuredMethodNames [candidate .detail .MethodName ] = struct {}{}
363- }
364-
365- if len (metadata .Spec .Methods ) > 0 {
366- continue
367- }
368- for _ , methodName := range methodNamesFromMetadataParameters (metadata .Spec .Parameters ) {
369- fallbackMethodNames [methodName ] = struct {}{}
370363 }
371364 }
372365
373- // Legacy metadata may only expose flat method-name parameters without structured method definitions.
374- // Keep those names as a fallback for method listing, but never let them shadow authoritative
375- // structured metadata for the same method name.
376- for methodName := range fallbackMethodNames {
377- if _ , ok := structuredMethodNames [methodName ]; ok {
378- continue
379- }
380- candidateByKey [serviceMethodKey (methodName , "" )] = newFallbackServiceMethodCandidate (methodName )
381- }
382-
383366 candidates := make ([]* serviceMethodCandidate , 0 , len (candidateByKey ))
384367 for _ , candidate := range candidateByKey {
385368 candidates = append (candidates , candidate )
@@ -429,12 +412,6 @@ func resolveStructuredServiceMethodCandidate(candidates []*serviceMethodCandidat
429412 )
430413 }
431414 if candidate == nil {
432- if hasFallbackOnlyMethodCandidate (candidates , req .MethodName ) {
433- return nil , bizerror .New (
434- bizerror .InvalidArgument ,
435- fmt .Sprintf ("structured metadata not found for method %s of service %s" , req .MethodName , req .ServiceName ),
436- )
437- }
438415 return nil , bizerror .New (
439416 bizerror .NotFoundError ,
440417 fmt .Sprintf ("method %s not found for service %s" , req .MethodName , req .ServiceName ),
@@ -449,15 +426,6 @@ func resolveStructuredServiceMethodCandidate(candidates []*serviceMethodCandidat
449426 return candidate , nil
450427}
451428
452- func hasFallbackOnlyMethodCandidate (candidates []* serviceMethodCandidate , methodName string ) bool {
453- for _ , candidate := range candidates {
454- if candidate .detail .MethodName == methodName && candidate .method == nil {
455- return true
456- }
457- }
458- return false
459- }
460-
461429func newStructuredServiceMethodCandidate (method * meshproto.Method ) (* serviceMethodCandidate , bool ) {
462430 if method == nil {
463431 return nil , false
@@ -473,38 +441,6 @@ func newStructuredServiceMethodCandidate(method *meshproto.Method) (*serviceMeth
473441 }, true
474442}
475443
476- func newFallbackServiceMethodCandidate (methodName string ) * serviceMethodCandidate {
477- return & serviceMethodCandidate {
478- detail : & model.ServiceMethodDetailResp {
479- MethodName : methodName ,
480- Signature : "" ,
481- ParameterTypes : []string {},
482- Parameters : []model.ServiceMethodParameter {},
483- Types : []model.ServiceMethodTypeResp {},
484- },
485- signature : "" ,
486- }
487- }
488-
489- func methodNamesFromMetadataParameters (parameters map [string ]string ) []string {
490- if parameters == nil {
491- return nil
492- }
493- methodsRaw := strings .TrimSpace (parameters ["methods" ])
494- if strutil .IsBlank (methodsRaw ) {
495- return nil
496- }
497- methodNames := make ([]string , 0 )
498- for _ , methodName := range strings .Split (methodsRaw , "," ) {
499- methodName = strings .TrimSpace (methodName )
500- if strutil .IsBlank (methodName ) {
501- continue
502- }
503- methodNames = append (methodNames , methodName )
504- }
505- return methodNames
506- }
507-
508444func serviceMethodKey (methodName , signature string ) string {
509445 return methodName + "\x00 " + signature
510446}
0 commit comments