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: drop a service row the definition outgrew instead of throwing the whole catalog

[._.]/ Adam Eivyafefe6f3d675
diff --git a/server/services/compositeProviders.js b/server/services/compositeProviders.js
index 8718819990..aaf67f5bf0 100644
--- a/server/services/compositeProviders.js
+++ b/server/services/compositeProviders.js
@@ -3,7 +3,7 @@ import { PROVIDER_HARNESSES, harnessById, isCompatible } from '../lib/providerHa
import { materializeRouteOutcome } from '../lib/providerRouteRecipes.js';
import { applyServicePlanFilter, instanceApiKeyFor } from '../lib/providerServiceInstances.js';
import { effortLevelsForProvider } from '../lib/providerModels.js';
-import { resolveServiceInstance, serviceDefinitionById } from '../lib/serviceDefinitions.js';
+import { SERVICE_SLUG_RE, resolveServiceInstance, serviceDefinitionById } from '../lib/serviceDefinitions.js';
import { bootstrapInputFor, listCredentialBootstraps, presentCredentialBootstraps } from './credentialBootstrapApps.js';
import { harnessEnablementFrom, harnessSettingsRevision, listHarnessEnablement } from './harnessEnablement.js';
import { findConnectionByRef, providerGraphEnabled } from './providerGraph.js';
@@ -85,6 +85,15 @@ async function graphWithinTtl() {
export function instanceForConnection(connection, env = process.env) {
const definition = connection?.definitionId ? serviceDefinitionById(connection.definitionId) : null;
if (!definition || !connection.slug) return null;
+ // A stored row OUTLIVES the definition it names: installs upgrade on their own
+ // schedule, so a release that drops or renames a plan leaves existing rows on
+ // the old one. `resolveServiceInstance` THROWS on a plan the definition no
+ // longer sells (and on a slug that predates SERVICE_SLUG_RE), and the catalog
+ // maps this over EVERY connection — so one stale row would take down the whole
+ // composition surface instead of dropping the single service it describes.
+ // Answer `null` for it, exactly as for a definition this build does not have.
+ const plan = connection.plan ?? definition.plans[0];
+ if (!definition.plans.includes(plan) || !SERVICE_SLUG_RE.test(connection.slug)) return null;
const apiKey = instanceApiKeyFor(connection, definition, env);
return resolveServiceInstance({
definition,
diff --git a/server/services/compositeProviders.test.js b/server/services/compositeProviders.test.js
index 7bfc2a9da2..06e9d56ccc 100644
--- a/server/services/compositeProviders.test.js
+++ b/server/services/compositeProviders.test.js
@@ -226,6 +226,17 @@ describe('materializeComposite — refusals carry a reason and never substitute'
expect(outcome.reason).toEqual(expect.any(String));
});
+ it('refuses — rather than throwing — a row whose stored plan the definition no longer sells', () => {
+ // Installs upgrade independently, so a row can outlive the plan it was
+ // written with. That must drop the one service, not throw out of the whole
+ // composition surface (the catalog resolves EVERY row in one pass).
+ const stale = { ...GRAPH, connections: GRAPH.connections.map((row) => (row.slug === 'nvidia-nim' ? { ...row, plan: 'retired-tier' } : row)) };
+ expect(composite.instanceForConnection(stale.connections.find((row) => row.slug === 'nvidia-nim'))).toBeNull();
+ expect(resolve('pi.tui@nvidia-nim', { graph: stale })).toMatchObject({ record: null, code: 'service-undefined' });
+ // A sibling row on a plan that still exists is unaffected.
+ expect(resolve('pi.tui@openrouter', { graph: stale }).record).not.toBeNull();
+ });
+
it('refuses a slug that only matches a connection UUID, so an id is never resolved by row identity', () => {
const byUuid = { ...GRAPH, connections: [{ ...GRAPH.connections[0], slug: 'nvidia-nim-renamed' }] };
expect(resolve('pi.tui@nvidia-nim', { graph: byUuid }).code).toBe('service-unknown');