Skip to content

fix: prepend context-path to contract reporter API paths#1803

Open
SkyeBeFreeman wants to merge 3 commits intoTencent:2024from
SkyeBeFreeman:fix/contract-reporter-context-path
Open

fix: prepend context-path to contract reporter API paths#1803
SkyeBeFreeman wants to merge 3 commits intoTencent:2024from
SkyeBeFreeman:fix/contract-reporter-context-path

Conversation

@SkyeBeFreeman
Copy link
Copy Markdown
Collaborator

Summary

  • When server.servlet.context-path (Servlet) or spring.webflux.base-path (WebFlux) is configured, PolarisContractReporter now prepends the context-path prefix to both InterfaceDescriptor paths and OpenAPI paths before reporting to Polaris.
  • Previously, paths were reported without the prefix (e.g., /quickstart/callee/sum instead of /callee-service/quickstart/callee/sum), causing a mismatch between actual endpoints and Polaris service contract data.
  • Added unit tests for PolarisContractReporter covering context-path prepending, empty context-path, and normalized context-path scenarios.

Test plan

  • Unit tests pass: mvn test -pl spring-cloud-starter-tencent-polaris-contract -Dtest=PolarisContractReporterTest (3/3 pass)
  • Module compiles successfully
  • Integration test with server.servlet.context-path=/callee-service configured — verify Polaris contract shows prefixed paths

🤖 Generated with Claude Code

SkyeBeFreeman and others added 2 commits March 26, 2026 17:46
When server.servlet.context-path or spring.webflux.base-path is configured,
PolarisContractReporter now prepends the context-path prefix to both
InterfaceDescriptor paths and OpenAPI paths before reporting to Polaris.
Previously, paths were reported without the prefix, causing a mismatch
between actual endpoints and Polaris service contract data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Haotian Zhang <928016560@qq.com>
Signed-off-by: Haotian Zhang <928016560@qq.com>
@SkyeBeFreeman SkyeBeFreeman requested a review from fuyuwei01 March 26, 2026 09:48
@SkyeBeFreeman SkyeBeFreeman added this to the 2.1.2.x milestone Mar 26, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 10.00000% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.61%. Comparing base (e1b9e07) to head (2433d3a).

Files with missing lines Patch % Lines
...ud/polaris/contract/tsf/TsfApiMetadataGrapher.java 0.00% 9 Missing ⚠️
...loud/polaris/contract/PolarisContractReporter.java 33.33% 6 Missing ⚠️
...ntract/config/PolarisSwaggerAutoConfiguration.java 0.00% 6 Missing ⚠️
...aris/contract/tsf/TsfSwaggerAutoConfiguration.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               2024    #1803      +/-   ##
============================================
+ Coverage     54.48%   54.61%   +0.12%     
  Complexity      152      152              
============================================
  Files           482      482              
  Lines         14060    14085      +25     
  Branches       1754     1763       +9     
============================================
+ Hits           7661     7692      +31     
+ Misses         5791     5776      -15     
- Partials        608      617       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Apply the same context-path fix to TsfApiMetadataGrapher as was done
for PolarisContractReporter. When server.servlet.context-path or
spring.webflux.base-path is configured, the OpenAPI paths are now
prefixed before serialization to the $api_metas system property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Haotian Zhang <928016560@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant