[Bug] A null or nameless entry in "providers" crashes startup with a TypeError
Description
Provider entries are not validated when they are loaded. A null entry (or an entry without name) makes config loading throw "Cannot read properties of null (reading 'name')" and the app does not start.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at 5df35b3a)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
-
In an empty folder create
agents.config.json:{"nanocoder":{"providers":[null,{"models":["m"]}]}} -
Run
getAppConfig()withNANOCODER_CONFIG_DIRset to an empty folder.
Expected Behavior
Each invalid entry is skipped with one clear message, for example providers[0] in <file> is not an object and providers[1] has no "name". The valid entries still load.
Actual Behavior
THROW TypeError: Cannot read properties of null (reading 'name')
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/config/mcp-config-loader.ts:260-275: the code callsproviderMap.set(provider.name, provider)for each entry. Filter entries first with a small validator (object, non-empty stringname,modelsis an array if present) and report each rejected entry once. The same validator should be used inloadProjectProviderConfigs(line 281) andloadProviderConfigFromFile(line 329).- Add tests for
null, a number and an object withoutname.
I'd like to take this one. Root cause: loadProjectProviderConfigs / the provider loop in source/config/mcp-config-loader.ts reads provider.name without checking the entry is an object, so a null item in providers throws TypeError: Cannot read properties of null (reading 'name') and aborts the whole config load (nameless entries are likewise passed through unvalidated).
Proposal: skip (with a logged warning) any provider entry that is not a non-null object with a string name, so the remaining valid providers still load; add a spec covering [null, valid] and a nameless entry, plus the patch changeset required by AGENTS.md.
Happy to open a PR with that if you're fine with me picking it up.
Disclosure: this comment was drafted with the help of an AI coding assistant (Claude) and reviewed before posting.