← Back to PRs

#22870: fix(config): allow modelByChannel in channels validation allowlist

by darcuri open 2026-02-21 19:26 View on GitHub →
size: XS
## 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