fix(server): quote startup curl example - #235
Conversation
Signed-off-by: nachiketb <nachiketb@nvidia.com>
WalkthroughThe startup banner now generates shell-safe curl examples. It quotes URLs and JSON bodies, uses loopback addresses for wildcard listeners, and brackets IPv6 URL authorities. ChangesStartup request examples
Estimated code review effort: 2 (Simple) | ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/switchyard-server/src/lib.rs (1)
970-978: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression tests for shell-safe examples.
Test an IPv6 listener and a route ID containing an apostrophe. Assert the generated command contains a bracketed IPv6 authority and the escaped apostrophe sequence in the JSON argument.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/switchyard-server/src/lib.rs` around lines 970 - 978, Add regression coverage for the startup example rendering around the shell_quote usage in the server banner formatter. Exercise an IPv6 listener and a route ID containing an apostrophe, asserting the generated curl command uses a bracketed IPv6 authority and preserves the shell-escaped apostrophe sequence in the JSON argument.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/switchyard-server/src/lib.rs`:
- Around line 1030-1032: Add a concise documentation comment immediately above
the private shell_quote function stating that it emits a POSIX shell
single-quoted argument and escapes embedded apostrophes; leave the
implementation unchanged.
---
Nitpick comments:
In `@crates/switchyard-server/src/lib.rs`:
- Around line 970-978: Add regression coverage for the startup example rendering
around the shell_quote usage in the server banner formatter. Exercise an IPv6
listener and a route ID containing an apostrophe, asserting the generated curl
command uses a bracketed IPv6 authority and preserves the shell-escaped
apostrophe sequence in the JSON argument.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 7a3e162c-6a6c-4e8f-83fb-a22245f51acb
📒 Files selected for processing (1)
crates/switchyard-server/src/lib.rs
What
Quotes the startup banner's example
curlcommand so it remains copy-pasteable when:http://[::1]:4000Also adds two concise comments documenting the non-obvious URL normalization behavior that CodeRabbit flagged.
Why
CodeRabbit was right: PR #234 could print invalid shell when a valid configured route id contained an apostrophe. A live server repro with route id
switchyard/it's-validshowed the original banner emitted:which breaks single-quoted shell parsing.
How
Adds a tiny
shell_quotehelper for the generated URL and JSON body. It wraps values in single quotes and escapes embedded apostrophes using the standard'\''shell representation.Validation
cargo check -p switchyard-servercargo fmtandcargo clippyswitchyard/it's-valid--host :: --port 0http://[::1]:.../v1/chat/completionsreturned200with modelswitchyard/it's-validNo test files were added.
Summary by CodeRabbit