Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: guard the migration's fallbackProvider lookup against Object.prototype keys (#3727)

[._.]/ Adam Eivy79d63895ebe4
diff --git a/scripts/migrations/246-fallback-model-retired-claude-ids.js b/scripts/migrations/246-fallback-model-retired-claude-ids.js
index 79c0453b37..ef24acda7a 100644
--- a/scripts/migrations/246-fallback-model-retired-claude-ids.js
+++ b/scripts/migrations/246-fallback-model-retired-claude-ids.js
@@ -104,7 +104,14 @@ export default {
// The pin is resolved against the fallback PROVIDER, not this one — so
// that is the model list it has to survive.
- const target = providers[provider.fallbackProvider];
+ // `Object.hasOwn` for the same reason as `replacementFor` below: `providers`
+ // comes from `JSON.parse` and still inherits `Object.prototype`, so a
+ // `fallbackProvider` of `constructor`/`toString` would otherwise resolve to
+ // a prototype member instead of reading as "provider is gone".
+ const targetId = provider.fallbackProvider;
+ const target = typeof targetId === 'string' && Object.hasOwn(providers, targetId)
+ ? providers[targetId]
+ : null;
if (!target) continue;
if (lists(target, pinned)) continue; // still resolves — leave it alone
diff --git a/scripts/migrations/246-fallback-model-retired-claude-ids.test.js b/scripts/migrations/246-fallback-model-retired-claude-ids.test.js
index a5cb7b153d..5403051b0f 100644
--- a/scripts/migrations/246-fallback-model-retired-claude-ids.test.js
+++ b/scripts/migrations/246-fallback-model-retired-claude-ids.test.js
@@ -123,6 +123,16 @@ describe('migration 246 — repair retired fallbackModel pins', () => {
expect(readJson(providersPath).providers.codex.fallbackModel).toBe('claude-opus-4-8');
});
+ it('skips a fallbackProvider named after an Object.prototype member', async () => {
+ const config = staleConfig();
+ config.providers.codex.fallbackProvider = 'constructor';
+ writeJson(providersPath, config);
+
+ await migration.up({ rootDir });
+
+ expect(readJson(providersPath).providers.codex.fallbackModel).toBe('claude-opus-4-8');
+ });
+
it('does not rewrite the file when nothing is stale', async () => {
const config = staleConfig();
config.providers.codex.fallbackModel = 'claude-opus-5';