Repository navigation
fix: config/models.yaml parsing failures - #206
Conversation
…il-safe LogConfigStatus was returning as soon as a later candidate path loaded successfully, so a broken ./models.yaml sitting next to a working config/models.yaml went unmentioned - the exact silence issue #204 was about. Now it always surfaces parse warnings before checking the source. Also promoted the healthy-path "config loaded" log from Debug to Info so it's visible at default verbosity, guarded against a nil logger since NewFactory now calls this unconditionally, and fixed a pre-existing test that mutated the config singleton without restoring it (flaky under -shuffle).
Two remaining silent-failure shapes from the #204 family: an empty or comment-only models.yaml is valid YAML and unmarshals cleanly, so it was being treated as a successful load with zero patterns or mappings inside. loadConfigFromFile now checks for that and warns + skips the candidate instead. Separately, the OLLA_CONFIG_DIR candidate collapsed to the same "models.yaml" as the first candidate whenever the env var was unset, double-reading (and double-warning on) the same broken file - only add that candidate when the env var is actually set, and dedupe the list.
WalkthroughThe change improves model configuration loading diagnostics and fallback handling, logs configuration status during factory initialisation, expands default model mappings, updates shipped YAML configuration, and adds validation tests. ChangesModel configuration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant NewFactory
participant LogConfigStatus
participant LoadModelConfig
participant ConfigCandidates
participant StyledLogger
NewFactory->>LogConfigStatus: log configuration status
LogConfigStatus->>LoadModelConfig: load configuration
LoadModelConfig->>ConfigCandidates: inspect candidate files
ConfigCandidates-->>LoadModelConfig: configuration or warning
LogConfigStatus->>StyledLogger: report source and warnings
Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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 `@internal/adapter/unifier/model_config.go`:
- Around line 75-88: Update the Go doc comments for LoadModelConfig and
ConfigSource to explain why process-wide caching via configOnce is required and
why configuration loading is deferred until an entry point is called. Retain the
existing behavioral details only as supporting context, while making the
comments focus on the rationale.
- Around line 77-81: The configOnce initialization around loadConfigFromFile and
configInstance.compilePatterns must fall back when pattern compilation fails:
replace configInstance with compiled embedded defaults, clear configSource, and
preserve the original compilation error in configParseWarnings before reporting
configuration details. Add a regression test using valid YAML containing an
invalid regular-expression pattern to verify the fallback and warning behavior.
- Around line 116-119: Update the warning logic around configParseWarnings and
configSource to distinguish empty-file warnings from parse failures and report
the actual unusable candidate cause. Use the final active configSource in the
message instead of always claiming embedded defaults, and add coverage for an
empty candidate plus a broken earlier candidate followed by a valid later
candidate.
- Around line 126-128: Update loadConfigFromFile to ignore os.ReadFile errors
only when errors.Is(err, fs.ErrNotExist); retain all other read errors in
configParseWarnings so unreadable candidates are not reported as absent. Add a
test using a directory named models.yaml and verify the resulting warning
behavior.
- Around line 191-195: Update ModelUnificationConfig.isEffectivelyEmpty to
include every populated configuration collection, including FamilyAliases,
PublisherMappings, TypeCapabilities, ContextThresholds, and both SpecialRules
lists, so any configured section is treated as usable. Add a test covering a
configuration file containing only family_aliases and verify it is not replaced
by embedded defaults.
🪄 Autofix
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: Pro Plus
Run ID: 49721cd1-6308-43cf-9b45-618e19b79359
📒 Files selected for processing (4)
config/models.yamlinternal/adapter/unifier/factory.gointernal/adapter/unifier/model_config.gointernal/adapter/unifier/model_config_test.go
| // LoadModelConfig loads the model unification configuration | ||
| func LoadModelConfig() (*ModelUnificationConfig, error) { | ||
| configOnce.Do(func() { | ||
| configInstance = loadConfigFromFile() | ||
| configInstance, configSource, configParseWarnings = loadConfigFromFile() | ||
| if configInstance != nil { | ||
| errConfig = configInstance.compilePatterns() | ||
| } | ||
| }) | ||
| return configInstance, errConfig | ||
| } | ||
|
|
||
| // loadConfigFromFile loads configuration from the YAML file | ||
| func loadConfigFromFile() *ModelUnificationConfig { | ||
| // ConfigSource returns the path models.yaml was loaded from, triggering the | ||
| // load if it hasn't happened yet. An empty string means embedded defaults | ||
| // are in use - check the returned warnings via LogConfigStatus to see why. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document the reason for these entry points.
The comments repeat API behaviour. State why process-wide caching and on-demand loading are necessary.
As per coding guidelines, Go comments must explain "why", not "what".
🤖 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 `@internal/adapter/unifier/model_config.go` around lines 75 - 88, Update the Go
doc comments for LoadModelConfig and ConfigSource to explain why process-wide
caching via configOnce is required and why configuration loading is deferred
until an entry point is called. Retain the existing behavioral details only as
supporting context, while making the comments focus on the rationale.
Source: Coding guidelines
| if len(configParseWarnings) > 0 { | ||
| log.Warn("model unification config: found models.yaml but could not parse it, falling back to embedded defaults", | ||
| "details", strings.Join(configParseWarnings, "; ")) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Report the actual warning cause and active source.
configParseWarnings also contains empty-file warnings, although the file parsed successfully. A later candidate can also set configSource, but this message still says embedded defaults are active.
Report an unusable candidate without claiming a parse failure or default fallback. Add coverage for an empty candidate and for a broken earlier candidate followed by a valid later candidate.
🤖 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 `@internal/adapter/unifier/model_config.go` around lines 116 - 119, Update the
warning logic around configParseWarnings and configSource to distinguish
empty-file warnings from parse failures and report the actual unusable candidate
cause. Use the final active configSource in the message instead of always
claiming embedded defaults, and add coverage for an empty candidate plus a
broken earlier candidate followed by a valid later candidate.
The empty-file guard added in 6f18508 only checked family_patterns, name patterns, quantization mappings and architecture mappings, so a valid partial file that only set (say) family_aliases was wrongly treated as empty and discarded. Now every top-level section counts.
If a candidate parsed as valid YAML but had a pattern that wasn't a valid regex, LoadModelConfig handed back the uncompiled config alongside the error, and getConfig() in metadata_extractor.go swapped in getDefaultConfig() - which is never compiled either. Every regex-driven lookup then silently no-opped instead of erroring or working. Now a compile failure is recorded as a warning naming the source, and the embedded defaults are built and compiled in its place.
The warning always said "falling back to embedded defaults", even when a later candidate loaded fine and defaults were never touched. Reworded to "found unusable models.yaml candidate(s)" and only claim the defaults fallback when configSource is actually empty - otherwise name the source that's really active.
os.ReadFile failing was always treated as "candidate doesn't exist" and skipped without comment. That's right for the common case (most of the search path is speculative) but wrong for a real problem like permission denied or a directory named models.yaml - those got the same silence as a file that was never there. Only fs.ErrNotExist is skipped silently now; anything else is recorded as a warning.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/adapter/unifier/model_config_test.go (1)
276-277: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove or replace this helper comment.
Line 276 repeats the helper behaviour. Remove it, or state why diagnostics must name the unusable candidate.
As per coding guidelines, “Comment on why, not what. Concise and direct.”
🤖 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 `@internal/adapter/unifier/model_config_test.go` around lines 276 - 277, Update the comment above requireWarningNaming to remove the redundant description of the helper’s behavior, or replace it with a concise rationale explaining why diagnostics must identify the unusable candidate.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@internal/adapter/unifier/model_config_test.go`:
- Around line 276-277: Update the comment above requireWarningNaming to remove
the redundant description of the helper’s behavior, or replace it with a concise
rationale explaining why diagnostics must identify the unusable candidate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1707a3c7-5697-4672-9cc5-ea0298aec487
📒 Files selected for processing (2)
internal/adapter/unifier/model_config.gointernal/adapter/unifier/model_config_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/adapter/unifier/model_config.go
The shipped
config/models.yamlused\dinside double-quoted YAML scalars, which is nota vaalid YAML escape, so the file has never parsed on any install.
loadConfigFromFile()swallowed the error and silently fell back to embedded defaults, meaning user customisations
(e.g. capability tagging via
name_patterns) were discarded with no diagnostic.Changes
\dare now single-quoted scalars.unifier.NewFactory()at boot, not lazily on first request). Olla logs the loaded sourceat
INFO, and a found-but-unparseable candidate atWARNwith the path and YAML error -including when a later candidate path loads successfully (a broken
./models.yamlshadowedby a valid
config/models.yamlwarns about both).models.yamlparses "successfully" asa config with no rules; it now warns and falls through to the next candidate instead.
OLLA_CONFIG_DIRunset, the env candidate collapsed to aduplicate of
./models.yaml, doubling warnings; the candidate is now only added when theenv var is set, and the list is deduped.
getDefaultConfig(). Both sides are now identical, guarded by an equivalence test so theycannot drift silently again.
Behaviour changes
config/models.yaml(and user copies of it) now actually take effect.INFO model unification config loaded source=...or aWARNonparse failure.
or only in code:
Q4_K_XL → q4kxl,llama4architecture mapping, and publisher mappingsfor falcon, vicuna, bloom, opt, gpt2, gptj and gptneox. Unified model IDs are unaffected -
these change metadata in
/olla/modelsonly.Tests
config/models.yamlmust unmarshal into the real struct and everyregex must compile.
\dconstruct), empty file, comment-only file - eachasserts the warning and clean fallback with no panic.
go test -shuffle) caused by singleton pollution.Not in this PR
Will be subsequent PRs.
--validate-configCLI switch / config hashing.profile.LoadProfiles()has the same silent-swallow pattern for broken profile YAMLs./internal/status.Summary by CodeRabbit
New Features
llama4architecture support.Q4_K_XLquantisation format.Bug Fixes
Tests