spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

route degrade bug

Open JunJieLiu51520 opened this issue 9 months ago • 3 comments

Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.

i wan't degrade to another route when invoke error with specify http code

Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.

  - id: gpt-4o
      metadata:
        name: gpt-4o
      uri: https://xxx-xxx-2.xxx-api.xxx
      predicates:
        - Path=/gpt-4o/api/v1/**
        - Weight=gpt-4o, 1
      filters:
        - RewritePath=/gpt-4o/api/v1/(?<segment>.*), /deployments/gpt-4o/${segment}
        - RemoveRequestHeader=Authorization
        - AddRequestHeader=Ocp-Apim-Subscription-Key, xxx
        - name: ModifyRequestBody
          args:
            inClass: java.lang.String
            outClass: java.lang.String
            rewriteFunction: com.ximalaya.infra.deepgate.filters.rewrite.RequestTransformer
            contentType: application/json
    - id: gpt-4o-xxx
      metadata:
        name: gpt-4o
        connect-timeout: 60000
      uri: https://xxx.xxx.com
      predicates:
        - Path=/xxx/api/v1/**
      filters:
        - RewritePath=/xxx/api/v1/(?<segment>.*), /test/v1/ai/xxx
        - RemoveRequestHeader=Authorization
        - AddRequestHeader=Authorization, Bearer xxx
        - name: ModifyRequestBody
          args:
            inClass: java.lang.String
            outClass: java.lang.String
            rewriteFunction: com.ximalaya.infra.deepgate.filters.rewrite.RequestTransformer
            contentType: application/json
        - name: CircuitBreaker
          args:
            name: gpt4oCircuitBreaker
            fallbackUri: forward:/gpt-4o
            statusCodes:
              - 401
              - 403
              - 404
              - 408
              - 502
              - 503
              - 504

JunJieLiu51520 avatar Apr 02 '25 09:04 JunJieLiu51520

when i debug the code for org.springframework.cloud.gateway.filter.factory.SpringCloudCircuitBreakerFilterFactory#apply, i found this under below

Image

the schema is null, another question is that this config way can't be trigger

JunJieLiu51520 avatar Apr 02 '25 09:04 JunJieLiu51520

anybody can help me ?

JunJieLiu51520 avatar Apr 02 '25 09:04 JunJieLiu51520

spring-cloud-circuitbreaker-filter-factory as document say : fallbackUri: forward:/gpt-4o the request is forwarded to the controller matched by the URI.

or unless /gpt-4o match any route

JoeCqupt avatar Apr 03 '25 08:04 JoeCqupt