#22870: fix(config): allow modelByChannel in channels validation allowlist
size: XS
Cluster:
Wizard Enhancements and Config Fixes
## Problem
When using the `channels.modelByChannel` config feature (added in #22315), the gateway fails to start with:
```
Invalid config: channels.modelByChannel: unknown channel id: modelByChannel
```
## Root Cause
The secondary validator in `src/config/validation.ts` iterates every key under `config.channels` and rejects anything not in `CHANNEL_IDS` or `"defaults"`. The `modelByChannel` key is a valid top-level `channels` entry — it's defined in the Zod schema (`ChannelsSchema` in `zod-schema.providers.ts`) and implemented in `model-overrides.ts` — but it was never added to the validator's allowlist.
## Fix
One-line: add `"modelByChannel"` to the `allowedChannels` set alongside `"defaults"`.
## Reproduction
Add a `modelByChannel` block to your `openclaw.json`:
```json
"channels": {
"modelByChannel": {
"discord": {
"123456789": "anthropic/claude-haiku-4-5"
}
}
}
```
Gateway startup will fail with the error above.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds `modelByChannel` to the validation allowlist in `src/config/validation.ts:240`, fixing a startup crash when the feature is used. The `modelByChannel` key is already defined in the Zod schema (`ChannelsSchema` in `zod-schema.providers.ts:34`) and implemented in `model-overrides.ts`, but was missing from the secondary validator's allowlist alongside `defaults`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The fix is a one-line addition that correctly aligns the runtime validator with the existing Zod schema definition. The change is minimal, focused, and directly addresses the reported bug without introducing new functionality or touching any other logic.
- No files require special attention.
<sub>Last reviewed commit: 5890a97</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23155: fix: add modelByChannel to allowed channel config keys
by tiagocampo · 2026-02-22
90.5%
#22998: fix(config): add modelByChannel to allowed channels keys
by bbekdemir · 2026-02-21
90.2%
#23211: fix: include modelByChannel in allowed channels validator
by westerbamos · 2026-02-22
89.2%
#19020: bugfix(gateway): Handle invalid model provider API config gracefully\…
by funkyjonx · 2026-02-17
78.8%
#9064: fix: validate model references against catalog in config.set/patch/...
by joetomasone · 2026-02-04
75.7%
#16388: Fix: Show model selector during onboarding for all auth choices
by saurav470 · 2026-02-14
74.2%
#18988: feat(config): add support for config warnings and improve validation
by saurav470 · 2026-02-17
73.7%
#21963: fix(cli): models fallbacks add now includes primary model in allowlist
by ashiabbott · 2026-02-20
73.1%
#12499: fix(config): add missing customBindHost to gateway Zod schema
by sfo2001 · 2026-02-09
72.6%
#19429: Fix/custom bind host validation
by frudas24 · 2026-02-17
72.5%