Skip to content

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

Open
decode2 wants to merge 2 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 2 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 to correctly handle formats with multiple separators (e.g., OpenRouter free models). The system now identifies the first separator character to distinguish provider from model ID and skips malformed specifications with leading separators.
  • Tests

    • Added test coverage for OpenRouter free model format parsing.
    • Updated backup path tests to use dynamic path resolution for platform compatibility.

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: 5d2ebcd4-d0c3-4406-93ac-ba88b5783db9

📥 Commits

Reviewing files that changed from the base of the PR and between 2eed5a1 and df7a9f0.

📒 Files selected for processing (3)
  • internal/components/sdd/read_assignments.go
  • internal/components/sdd/read_assignments_test.go
  • internal/update/upgrade/executor_test.go

📝 Walkthrough

Walkthrough

Fixes the colon-first separator bug in ReadCurrentModelAssignments by scanning for the first / or : character instead of using a colon-first then slash fallback, removes the now-unused strings import, and adds a regression test for OpenRouter free-model specs. 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 logic and regression test
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.

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) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing model spec parsing to handle multiple slashes and colons correctly in the first separator.
Linked Issues check ✅ Passed The PR directly addresses issue #802 by fixing the read-path parser in read_assignments.go to split at the first separator (slash or colon) instead of the first colon, with test coverage.
Out of Scope Changes check ✅ Passed All changes align with the stated objective of fixing model spec parsing in the read-path parser. The test file update in executor_test.go is a necessary maintenance change to use platform-correct path helpers.
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 and usage tips.

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

1 participant