Skip to content

fix(model): parse model specs with multiple slashes and colons correctly#930

Open
decode2 wants to merge 4 commits into
Gentleman-Programming:mainfrom
decode2:fix/model-spec-parsing-issue-802
Open

fix(model): parse model specs with multiple slashes and colons correctly#930
decode2 wants to merge 4 commits into
Gentleman-Programming:mainfrom
decode2:fix/model-spec-parsing-issue-802

Conversation

@decode2

@decode2 decode2 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Fixes model spec parsing in \ReadCurrentModelAssignments\ to correctly handle specs with multiple slashes and colons like \openrouter/qwen/qwen3.6-plus:free.

Problem

The read-path parser was splitting on the first colon before checking for slashes. This broke model specs where the provider is before the first slash, not before the colon.

For example, \openrouter/qwen/qwen3.6-plus:free\ was incorrectly parsed as:

  • ProviderID: \openrouter/qwen/qwen3.6-plus\
  • ModelID: \ ree\

When it should be:

  • ProviderID: \openrouter\
  • ModelID: \qwen/qwen3.6-plus:free\

Solution

Changed the parsing logic to find the first separator (either /\ or :) instead of preferring colon-first. This aligns with the write-path parser in \parseModelSpec\ (sync.go) which already handles this correctly.

Changes

  • Modified \internal/components/sdd/read_assignments.go\ to iterate through the string and find the first /\ or :\ character
  • Removed unused \strings\ import
  • Added test \TestReadCurrentModelAssignmentsOpenRouterFreeModel\ to verify OpenRouter free-model specs are parsed correctly

Testing

All existing tests pass, including:

  • Colon-separated specs: \�nthropic:claude-sonnet-4-20250514\
  • Slash-separated specs: \zai-coding-plan/glm-5-turbo\
  • Mixed separators in the same file
  • New test for OpenRouter free-model specs: \openrouter/qwen/qwen3.6-plus:free\

Fixes #802

Summary by CodeRabbit

  • Bug Fixes

    • Improved model specification parsing for OpenRouter “free model” formats by splitting on the first separator (/ or :) and correctly deriving provider/model IDs, including cases with multiple separator characters. Malformed specs (including leading/empty separators) are now skipped instead of misparsed.
  • Tests

    • Added unit tests covering OpenRouter free-model parsing for current assignments and profile detection.
    • Updated backup-related path assertions to use dynamically resolved runtime/config paths for better cross-platform consistency.

decode2 added 2 commits June 17, 2026 10:26
The test was hardcoding Unix-style paths (~/.config/gga/config) but
gga.ConfigPath() uses %APPDATA%\gga\config on Windows. Use the gga
package functions to get platform-correct paths instead of hardcoding.

This ensures the test works correctly on all platforms.
The read-path parser in ReadCurrentModelAssignments was splitting on
the first colon before checking for slashes. This broke model specs
like 'openrouter/qwen/qwen3.6-plus:free' where the provider is before
the first slash, not before the colon.

Changed the parsing logic to find the first separator (either '/' or
':') instead of preferring colon-first. This aligns with the write-path
parser in parseModelSpec (sync.go) which already handles this correctly.

Added test coverage for OpenRouter free-model specs with the format
'provider/org/model:variant'.

Fixes Gentleman-Programming#802
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 952d6440-1078-47db-93db-2e0582364abc

📥 Commits

Reviewing files that changed from the base of the PR and between 1b55f81 and f7bc6c3.

📒 Files selected for processing (1)
  • internal/components/sdd/profiles_test.go

📝 Walkthrough

Walkthrough

Fixes the colon-first separator bug in ReadCurrentModelAssignments and extractModelFromAgent by scanning for the first / or : character instead of using a colon-first then slash fallback, and adds regression tests for OpenRouter free-model specs in both paths. Separately updates a GGA backup-scope test to derive expected paths via gga.ConfigPath and gga.RuntimePRModePath instead of hardcoded strings.

Changes

SDD model spec first-separator fix

Layer / File(s) Summary
First-separator parsing in ReadCurrentModelAssignments
internal/components/sdd/read_assignments.go, internal/components/sdd/read_assignments_test.go
Replaces the colon-first then slash fallback in ReadCurrentModelAssignments with a scan for the first / or : character; removes the now-unused strings import; skips entries where no separator is found or the separator is at position 0. Adds TestReadCurrentModelAssignmentsOpenRouterFreeModel asserting that openrouter/qwen/qwen3.6-plus:free yields ProviderID=openrouter and ModelID=qwen/qwen3.6-plus:free.
First-separator parsing in extractModelFromAgent
internal/components/sdd/profiles.go, internal/components/sdd/profiles_test.go
Updates extractModelFromAgent to scan left-to-right for the first occurrence of / or : instead of trying : first with fallback to /; returns zero-value ModelAssignment when separator is missing or model ID is empty. Adds TestExtractModelFromAgent_OpenRouterFreeModel verifying the openrouter/qwen/qwen3.6-plus:free parse path and TestDetectProfiles_OpenRouterFreeModel verifying end-to-end profile detection with free-model specs.

GGA backup test path correction

Layer / File(s) Summary
Platform-correct GGA paths in backup test
internal/update/upgrade/executor_test.go
Adds internal/components/gga import and replaces hardcoded GGA config and pr_mode.sh path strings in TestConfigPathsForBackup_GGAExtrasAreIncluded with gga.ConfigPath(homeDir) and gga.RuntimePRModePath(homeDir).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes a change to executor_test.go unrelated to the main model parsing fix. While the change uses gga helper functions appropriately, it is outside the scope of issue #802 which only addresses model spec parsing bugs. Separate the executor_test.go change into a different PR or clarify its connection to the model spec parsing objectives.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main fix: parsing model specs with multiple slashes and colons correctly by finding the first separator.
Linked Issues check ✅ Passed All objectives from issue #802 are met: the parser now splits at the first separator (slash or colon) rather than colon-first, fixing the OpenRouter free-model parsing bug in both read_assignments.go and profiles.go with comprehensive test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@Alan-TheGentleman Alan-TheGentleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The ReadCurrentModelAssignments fix looks right, but #802 also calls out the same parsing bug in internal/components/sdd/profiles.go. That path still parses colon-first, so openrouter/qwen/qwen3.6-plus:free gets split incorrectly for named SDD profiles. Please update the profile parsing path to use the same first-separator logic and add a regression test through DetectProfiles or extractModelFromAgent.

Apply same fix as read_assignments.go to profiles.go: find the first
separator (either '/' or ':') instead of preferring colon-first.

This fixes parsing of specs like 'openrouter/qwen/qwen3.6-plus:free'
where the provider is before the first slash, not before the colon.

Added test TestExtractModelFromAgent_OpenRouterFreeModel to verify
the fix works correctly for named SDD profiles.

Addresses review feedback from Alan-TheGentleman on PR Gentleman-Programming#930
@decode2

decode2 commented Jun 20, 2026

Copy link
Copy Markdown
Author

@Alan-TheGentleman Applied the same fix to profiles.go as requested.

The extractModelFromAgent function now finds the first separator (either '/' or ':') instead of preferring colon-first, matching the fix in read_assignments.go.

Added test TestExtractModelFromAgent_OpenRouterFreeModel to verify that 'openrouter/qwen/qwen3.6-plus:free' is parsed correctly for named SDD profiles.

Both parsing paths now handle multi-slash/colon specs consistently.

@decode2

decode2 commented Jun 23, 2026

Copy link
Copy Markdown
Author

Hi @Alan-TheGentleman, the changes are complete:

  • Updated both parsing paths (\ReadCurrentModelAssignments\ and \�xtractModelFromAgent/\DetectProfiles) to scan for the first /\ or :\ character left-to-right rather than preferring colon-first.
  • Added \TestDetectProfiles_OpenRouterFreeModel\ regression coverage to assert that multi-slash/colon OpenRouter free model specs parse correctly for named SDD profiles.

Ready for re-review!

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.

fix(model): provider/model specs split at first colon even when a slash comes first

2 participants