Skip to content

feat: add gRPC naming scheme validation for subgraph routing URLs#2473

Merged
alepane21 merged 6 commits intomainfrom
ale/eng-8773-controlplane-should-check-routing-url-of-grpc-services
Jan 30, 2026
Merged

feat: add gRPC naming scheme validation for subgraph routing URLs#2473
alepane21 merged 6 commits intomainfrom
ale/eng-8773-controlplane-should-check-routing-url-of-grpc-services

Conversation

@alepane21
Copy link
Copy Markdown
Contributor

@alepane21 alepane21 commented Jan 27, 2026

We need to check the routing url sent for grpc service: grpc services have a different and stricter requirement than other urls. If not checking on the controlplane, the users will only see the issue at runtime in the router at the first request toward the gRPC service ... not a good time to see an error!

Summary by CodeRabbit

  • New Features

    • gRPC service subgraphs now validate routing URLs against supported gRPC naming schemes (DNS, Unix sockets, IPv4/IPv6, vsock). HTTP/HTTPS routing URLs for gRPC services are rejected with a clear guidance message.
  • Tests

    • Comprehensive tests added for routing URL validation across create, publish, and update flows.
    • Test utilities updated with new gRPC-specific default routing URL constants.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 27, 2026

Walkthrough

Adds runtime validation for SubgraphType.GRPC_SERVICE routing URLs via a new exported utility isValidGrpcNamingScheme; integrates the check into create/publish/update subgraph flows and updates tests and test constants to use gRPC-style routing URL values.

Changes

Cohort / File(s) Summary
Core gRPC Validation Utilities
controlplane/src/core/util.ts
Adds export function isValidGrpcNamingScheme(url: string): boolean plus helper validators (isValidPort, isValidHostname, isValidHostOrIpv4, isValidHostPort, isValidDnsTarget) and imports isIPv4/isIPv6.
gRPC Validation Tests
controlplane/src/core/util.test.ts
Adds comprehensive tests for isValidGrpcNamingScheme covering dns, unix (path/abstract), vsock, ipv4/ipv6, ports, and invalid HTTP/HTTPS/edge cases.
Subgraph Service Handlers
controlplane/src/core/bufservices/subgraph/createFederatedSubgraph.ts, controlplane/src/core/bufservices/subgraph/publishFederatedSubgraph.ts, controlplane/src/core/bufservices/subgraph/updateSubgraph.ts
Integrates isValidGrpcNamingScheme checks for SubgraphType.GRPC_SERVICE routingUrl; returns ERR with a detailed message when routingUrl does not match gRPC naming scheme; imports isValidGrpcNamingScheme.
Test Constants
controlplane/test/test-util.ts
Adds DEFAULT_GRPC_SUBGRAPH_URL_ONE, DEFAULT_GRPC_SUBGRAPH_URL_TWO, DEFAULT_GRPC_SUBGRAPH_URL_THREE ('localhost:4001', 'localhost:4002', 'localhost:4003').
Subgraph Operation Tests
controlplane/test/subgraph/...
controlplane/test/subgraph/create-subgraph.test.ts, controlplane/test/subgraph/publish-subgraph.test.ts, controlplane/test/subgraph/update-subgraph.test.ts
Replaces HTTP-style URLs with GRPC constants; adds tests rejecting HTTP/HTTPS for GRPC_SERVICE and accepting valid gRPC naming schemes; adjusts assertions and routing URL formats.
Feature & Feature-Flag Tests
controlplane/test/feature-subgraph/*, controlplane/test/feature-flag/feature-flag-with-grpc-service-fs.test.ts
Swap routingUrl references to use DEFAULT_GRPC_SUBGRAPH_URL_* constants across feature and feature-flag tests.
Miscellaneous Test Updates
controlplane/test/feature-subgraph/*, controlplane/test/subgraph/*
Minor import and constant substitutions to use GRPC-specific defaults; some assertions updated accordingly.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding gRPC naming scheme validation for subgraph routing URLs, which aligns with all modified files across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 84.95146% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.31%. Comparing base (3816a75) to head (2470b69).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
controlplane/src/core/util.ts 81.32% 31 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2473       +/-   ##
===========================================
+ Coverage   28.34%   63.31%   +34.96%     
===========================================
  Files         127      296      +169     
  Lines       11144    41686    +30542     
  Branches      243     4391     +4148     
===========================================
+ Hits         3159    26394    +23235     
- Misses       7981    15270     +7289     
- Partials        4       22       +18     
Files with missing lines Coverage Δ
...re/bufservices/subgraph/createFederatedSubgraph.ts 90.58% <100.00%> (ø)
...e/bufservices/subgraph/publishFederatedSubgraph.ts 89.52% <100.00%> (ø)
...ne/src/core/bufservices/subgraph/updateSubgraph.ts 83.33% <100.00%> (ø)
controlplane/src/core/util.ts 81.59% <81.32%> (ø)

... and 419 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alepane21
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 27, 2026

✅ Actions performed

Full review triggered.

@alepane21 alepane21 marked this pull request as ready for review January 28, 2026 08:38
Comment thread controlplane/src/core/util.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@controlplane/src/core/util.ts`:
- Around line 769-805: The DNS naming handling currently accepts
"dns://authority" with no host:port; update isValidGrpcNamingScheme to require a
host:port path when the scheme is "dns" and rest starts with "//": after
computing scheme and rest, if scheme === 'dns' and rest.startsWith('//') then
slice off the '//' (const remainder = rest.slice(2)), find const slashIndex =
remainder.indexOf('/'), return false if slashIndex === -1 or the endpoint after
the slash is empty, otherwise validate the endpoint with
isValidHostPort(endpoint); keep existing fallback behavior for other schemes and
for cases where rest does not start with "//". Ensure you reference
isValidGrpcNamingScheme, isValidDnsTarget, and isValidHostPort when making this
change.

Comment thread controlplane/src/core/util.ts
@alepane21 alepane21 requested a review from pepol January 28, 2026 10:56
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@controlplane/src/core/util.test.ts`:
- Around line 300-305: The test case asserting
isValidGrpcNamingScheme('dns://example.com:8080') contradicts the validator
which treats '//' as an authority indicator and expects an authority/path form;
update the test in controlplane/src/core/util.test.ts to use the non-authority
form (e.g., 'dns:example.com:8080') so the expectation remains true when calling
isValidGrpcNamingScheme.

Comment thread controlplane/src/core/util.test.ts
@alepane21 alepane21 merged commit 4d29351 into main Jan 30, 2026
12 checks passed
@alepane21 alepane21 deleted the ale/eng-8773-controlplane-should-check-routing-url-of-grpc-services branch January 30, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants