Repository navigation
fix(config): load provider shortcuts from cora yaml - #178
Conversation
ajianaz
left a comment
There was a problem hiding this comment.
Review: Approved ✅
What it does
Adds support for top-level model:, base_url:, and bare-string provider: in .cora.yaml, so users can write:
provider: openai
model: glm-5.1
base_url: https://api.z.ai/api/coding/paas/v4instead of needing the nested format:
provider:
provider: openai
model: glm-5.1
base_url: https://api.z.ai/api/coding/paas/v4Code Quality
| Aspect | Verdict |
|---|---|
| Logic correctness | ✅ deserialize_provider_section with untagged enum handles both bare string and section correctly |
| Merge precedence | ✅ Top-level model/base_url applied first, then nested provider: section can override — more specific wins |
Edge case: provider: null |
✅ Returns Ok(None) |
Edge case: bare provider: openai |
✅ Wraps into ProviderSection { provider: Some("openai"), ..Default::default() } |
| Tests | ✅ New test covers the exact scenario from issue #176 |
| Format / Clippy | ✅ Clean locally |
| Backward compat | ✅ Nested format still works, nothing breaks |
Minor observations (non-blocking)
-
model+provider.modelconflict: If user writes both top-levelmodel: glm-5.1AND nestedprovider: { model: gpt-4o }, the nested one wins (applied second). This is the correct behavior but not documented. Consider a note in docs. -
providerfield has dual types now: The custom deserializer handles this cleanly, but it means.cora.yamlschema is no longer a simple struct — tooling (schema validators, IDE yaml completion) might not understand the polymorphicproviderfield. Low impact for now.
Test Results
cargo test merge_top_level_provider_shortcuts — PASS
cargo test config::schema::tests (51 tests) — ALL PASS
cargo fmt --check — PASS
cargo clippy — PASS
LGTM — ready to merge after maintainer approval. Fixes the real pain point from #176.
- Change trigger from pull_request to pull_request_target for write access - Explicit checkout of PR head SHA for correct diff - Bump version 0.4.1 → 0.4.2 - Includes provider shortcuts from PR #178 Co-authored-by: Zeko (Hermes) <[email protected]>
Summary
.cora.yamlprovider shortcuts (provider: openai,model: ...,base_url: ...) in addition to the existing nestedprovider:mapping.Test Plan
cargo test config::schema::tests::merge_top_level_provider_shortcuts --quietcargo test config::schema::tests --quietcargo test --test config_loading --quietcargo fmt --checkcargo test --quietCloses #176