fix: accept both hyphen and underscore in v2 profile type names#22
Merged
ayushag-nv merged 1 commit intoJul 7, 2026
Merged
Conversation
Signed-off-by: Hiroshi Morishige <hiroshi.morishige@gmail.com>
ayushag-nv
approved these changes
Jul 7, 2026
ayushag-nv
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Thanks for the contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the v2 profile config (
switchyard serve --config profiles.yaml) treat-and_as equivalent in thetype:discriminator, so a profile type spelled with either separator resolves to the same profile.Why
The quickstart teaches the legacy route bundle with snake_case type names (
type: random_routing), while v2 profile configs use hyphenated names (random-routing,llm-routing,latency-service). Copyingtype: random_routinginto aprofiles.yamlfails withunknown profile type. Since #20 the v2 names are themselves mixed (random-routingvsstage_router), so either separator is a reasonable spelling for any type.This is the code-unification follow-up to #19 (a docs note), per the request there to fix it in code rather than documentation. #19 is closed in favor of this.
How
parse_profile_config(the generated dispatch inprofiles/macros.rs) now compares the requestedtypeagainst each registered profile type treating-and_as equal, via a small non-allocating byte scan. Single dispatch point; no per-profile or macro-attribute changes. Unknown types still error with the user's original spelling.random_routing→random-routingstage-router→stage_routerllm-routing,latency-service, etc. all resolveTests
tests/config.rs::profile_type_separators_are_normalized_during_resolution:llm_routing,stage-router, andlatency_serviceresolve to their canonical types and build.cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspaceall pass (toolchain 1.94.0).Notes
stage_router) configs are unaffected.--configpath (the failing side); the deprecated--routing-profilesbundle is unchanged.parse_profile_config). The resolved plan and runtime always report the canonical type name;ProfileConfigDocument::profile_type()still echoes the spelling written in the file. If you'd rather have the document accessor also report the canonical name, I can canonicalize at ingestion instead — let me know your preference.