-
Notifications
You must be signed in to change notification settings - Fork 129
chore(guard): simplify gateway routing #3339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(guard): simplify gateway routing #3339
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
PR Review: Simplify Gateway RoutingOverviewThis PR successfully simplifies the gateway routing pattern from a verbose multi-segment approach to a cleaner, more intuitive @ syntax. The changes are consistent across both Rust (guard) and TypeScript (RivetKit) implementations. Old format: Code Quality ✅Rust Implementation (guard/src/routing/mod.rs)Strengths:
Potential Issues:
TypeScript Implementation (rivetkit/src/manager/gateway.ts)Strengths:
Potential Issues:
Test Coverage ✅Rust Tests (parse_actor_path.rs)Excellent coverage:
Test quality: Very thorough, with good edge case coverage TypeScript Tests (parse-actor-path.test.ts)Good coverage matching Rust tests:
Minor gap: No test for multiple @ signs like Rust has Potential Bugs 🔍1. No Encoding Validation for @ in URLsThe @ symbol is a reserved character in URLs (RFC 3986). While it's valid in the path component, clients might inadvertently encode it as
2. Token Security ConsiderationTokens are now exposed in URL paths, which means:
3. Prefix Length Calculation Edge CaseIn both implementations (Rust line 210, TS line 417-420): let prefix_len = 1 + segments[0].len() + 1 + segments[1].len();This assumes the path starts with Performance Considerations 👍Improvements:
No concerns - the simplification improves performance Security Considerations
|
0454643 to
d9f9f0c
Compare
02256ed to
7ee6720
Compare
Pull Request ReviewSummaryThis PR simplifies the gateway routing by reducing URL verbosity. The changes replace the verbose routing pattern /gateway/actors/{actor_id}/tokens/{token}/route/{path} with the more concise /gateway/{actor_id}@{token}/{path} pattern. Positive Aspects1. Code Quality & Simplification
2. Test Coverage
3. Documentation
Code Quality Observations1. Rust Implementation (engine/packages/guard/src/routing/mod.rs) The implementation is clean and efficient. The code at line 194 uses find('@') which only finds the first occurrence - this is correct behavior (tokens can contain @ characters), and the test validates this. Good defensive programming. 2. TypeScript Implementation (rivetkit-typescript/packages/rivetkit/src/manager/gateway.ts) The TypeScript implementation mirrors the Rust logic perfectly, which is excellent for consistency. 3. Path Calculation Logic Both implementations use the same approach for calculating remaining path. The Rust version uses direct calculation while TypeScript uses a loop - both are correct, though the Rust approach is slightly more efficient. Potential Issues & Considerations1. Backward Compatibility
2. Token Security Consideration
3. URL Encoding
4. Removed Headers
Minor Suggestions1. Consider Edge Cases
2. Documentation
3. Error Messages Security ConsiderationsGood:
Consider:
PerformanceNo performance concerns. The new implementation is actually more efficient:
Recommendations
Overall AssessmentThis is a well-implemented refactoring that simplifies the routing logic significantly. The code is clean, well-tested, and consistent across both Rust and TypeScript implementations. The main concern is around backward compatibility and ensuring existing clients won't break. Recommendation: Approve pending clarification on backward compatibility impact. Review generated with Claude Code |
d9f9f0c to
705c6ca
Compare
7ee6720 to
4a27884
Compare
PR Review: Simplify Gateway RoutingSummaryThis PR simplifies the gateway routing by changing from a verbose path structure ( Positive Aspects
Code Quality Issues1. Potential Security Issue: Token Exposure in URLsUsing
Recommendation: Consider if this is intentional. If tokens are meant to be secrets, they should be in headers (existing 2. Code Inconsistency: Redundant Check in TypeScriptIn // Check for empty actor segment
if (actorSegment.length === 0) {
return null;
}This check is redundant because the segment comes from splitting on Note: The Rust version has the same check (line 187-189), so this is consistent but still redundant in both implementations. 3. Performance: Multiple @ Sign HandlingThe test Recommendation: Document this behavior or consider validating that tokens don't contain 4. Missing URL Encoding ConsiderationsWhile there's a test for URL-encoded characters in the remaining path, there's no handling or documentation for:
The current implementation would parse
This might be correct, but it's worth explicitly documenting. 5. Rust-Specific: String AllocationIn (aid.to_string(), Some(tok.to_string()))
} else {
(actor_id_segment.to_string(), None)
};These Potential Bugs6. Edge Case: Leading Slash in Remaining PathThe logic at lines 220-224 (Rust) and 432-436 (TypeScript) tries to ensure the remaining path starts with let remaining_path = if remaining_base.is_empty() || !remaining_base.starts_with('/') {
format!("/{}{}", remaining_base, query_string)
} else {
format!("{}{}", remaining_base, query_string)
};Since
The condition Performance ConsiderationsThe changes should have positive performance impact:
Security Concerns
Recommendation: Consider adding reasonable length limits (e.g., 1024 chars for actor_id/token). Test CoverageExcellent - The tests are comprehensive and cover:
Missing tests to consider adding:
Style & Convention Adherence✅ Follows CLAUDE.md conventions:
Recommendations SummaryMust Fix:
Should Consider:
Nice to Have: Overall AssessmentThis is a well-executed refactor that significantly improves the API ergonomics. The code is clean, well-tested, and consistent across implementations. The main concern is the security implications of tokens in URL paths, which may be acceptable depending on the use case but should be explicitly considered. Recommendation: Approve with minor considerations for the security/documentation items mentioned above. |
Pull Request ReviewSummaryThis PR simplifies the gateway routing by changing the URL pattern from the verbose /gateway/actors/{actor_id}/tokens/{token}/route/{...path} to the more concise /gateway/{actor_id}@{token}/{...path}. This is a great simplification that improves the API ergonomics significantly. Code Quality - APPROVEDPositive aspects:
Security Considerations - APPROVEDToken handling:
Path traversal:
Recommendations:
Test Coverage - EXCELLENTComprehensive test coverage includes:
Performance - IMPROVEDImprovements:
Potential Issues1. Breaking change handling:
2. Token visibility in URLs:
3. Character restrictions: Code Style - FOLLOWS CONVENTIONSFollows repository conventions:
Client Update Verification - COMPLETEAll client code updated correctly:
Overall AssessmentVerdict: APPROVE with minor suggestions This is a well-implemented refactoring that:
The code is production-ready. Main concern is ensuring this breaking change is properly communicated to users. Recommended actions before merge:
|
4a27884 to
dc31f94
Compare
PR Review: Gateway Routing SimplificationSummaryThis PR simplifies the gateway routing by changing from a verbose path structure ( ✅ Strengths
🔍 Code Quality Observations1. Potential Security Consideration - Multiple
|
Merge activity
|

No description provided.