Skip to content

[BUG] RequestTemplate.request() concatenates url with null path — literal null segment in request URL #6855

Closed

Description

@Aias00

Description

SpringMvcContract.parseRequestTemplate constructs new RequestTemplate() (field path defaults to null) and only calls setPath when methodMapping.value().length > 0. A method such as @GetMapping String health() (valid Spring MVC, maps to the class root) leaves path == null. ShenyuClientInvocationHandler.buildMethodHandlerMap then does requestTemplate.setPath(shenyuClientFactoryBean.getPath() + requestTemplate.getPath()) — with a class-level @ShenyuClient(path="/api"), "/api" + null evaluates to "/apinull". With no class path, RequestTemplate.request() line 82 does this.url + this.path → url + null → "http://hostnull". Java string concatenation appends the literal "null".

Location

  • shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/common/RequestTemplate.java:82
  • shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java:80-94
  • shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientInvocationHandler.java:110-112

Impact

Any @ShenyuClient method whose @RequestMapping/@GetMapping has no value (root-mapped) issues requests to a corrupted URL ending in null (e.g. http://gateway/apinull or http://gatewaynull), silently 404'ing or hitting the wrong path. This is a common, valid Spring-MVC annotation pattern.

Suggested fix

Default path to "" in RequestTemplate (or guard request(): this.url + (this.path == null ? "" : this.path)); ensure SpringMvcContract sets path to "" when no value is present.

Related existing

None — distinct from #6632 (GW-SYNC-2, AbstractNodeDataSyncService wrong key segment, unrelated module).

Activity

  1. github-actions commented on Aug 4, 2026

    @github-actions
    Contributor

    👋 Hello @Aias00

    A new issue has been opened by @Aias00:

    Please review when you have time. Thank you! 🙏

  2. yykaue commented on Aug 21, 2026

    @yykaue
    Contributor

    /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions