fix: guard initConfig against silent config reset on empty file load#36
fix: guard initConfig against silent config reset on empty file load#36bob56621517 wants to merge 1 commit into
Conversation
When global or project config files are transiently inaccessible
(I/O contention, race condition, missing files), loadConfigFromPaths()
returns {}. Calling buildConfig({}) fills all fields with hardcoded
defaults, then Object.assign(CONFIG, ...) overwrites the correctly
initialized CONFIG singleton — silently breaking user-configured
embedding model, dimensions, and API endpoint.
The Web UI migration detection (/api/migration/detect) reads
CONFIG.embeddingDimensions and CONFIG.embeddingModel to compare
against shard metadata, so the reset manifests as a false dimension
mismatch warning.
Fix: skip CONFIG rebuild entirely when both config sources are empty.
Closes ZeR020#35
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesConfig Guard Against Silent Reset
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| JavaScript | Jun 4, 2026 7:22a.m. | Review ↗ | |
| Secrets | Jun 4, 2026 7:22a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
|
@ZeR020 This PR is ready for review. It fixes a bug where silently resets CONFIG to hardcoded defaults when the global config file is transiently inaccessible, causing false dimension mismatch warnings in the Web UI. Changes: Single-file fix in — adds a guard to skip CONFIG rebuild when config sources are empty. CI note: The DeepSource JavaScript failure appears pre-existing (not from this change — only 11 lines of guard logic added). CodeRabbit skipped. Secrets check passed. Please review when available. Thanks! |
Problem
initConfig()insrc/config.tscan silently reset the entire CONFIG to hardcoded defaults whenloadConfigFromPaths()returns an empty object{}. This happens when the global config file is transiently inaccessible (I/O contention, file lock, race condition).When triggered,
buildConfig({})fills all fields with defaults (768D Xenova/nomic-embed-text-v1), thenObject.assign(CONFIG, ...)overwrites the correctly initialized CONFIG — silently breaking user-configured embedding model, dimensions, and API endpoint.The Web UI migration detection then reports a false dimension mismatch because CONFIG values no longer match shard metadata.
Fix
Add a guard in
initConfig()— when both global and project config sources are empty, skip the CONFIG rebuild entirely and preserve the existing values from module-level initialization.Testing
node --checkpassesCloses #35
Summary by CodeRabbit