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: resolve "Provider not found" when changing default AI provider (#32)

Adam Eivy39e29e06ffe1
diff --git a/.changelog/v1.17.x.md b/.changelog/v1.17.x.md
index 75f39c636e..b40d3fdb7d 100644
--- a/.changelog/v1.17.x.md
+++ b/.changelog/v1.17.x.md
@@ -11,3 +11,8 @@ Split monolithic "Blood & Body" tab into separate focused pages for better navig
- **Separate MeatSpace pages** — split the "Blood & Body" tab into 4 independent pages: Age (epigenetic), Blood (tests), Body (composition), and Eyes (prescriptions)
- **Dedicated sidebar nav entries** — each health domain now has its own sidebar link with distinct icons (Clock, HeartPulse, Scale, Eye)
- **Correct overview tile navigation** — overview health tiles now link directly to their respective pages instead of all pointing to Blood
+
+## Fixes
+
+- **Fix "Provider not found" when changing default AI provider** — `PUT /active` was caught by the wildcard `PUT /:id` route, treating "active" as a provider ID; added explicit route before the wildcard (fixes #32)
+- **Fix unhandled promise rejection on provider switch** — `handleSetActive` now catches errors gracefully instead of letting them bubble as unhandled rejections
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsx
index b55f640e01..67e87b2599 100644
--- a/client/src/pages/AIProviders.jsx
+++ b/client/src/pages/AIProviders.jsx
@@ -68,8 +68,9 @@ export default function AIProviders() {
};
const handleSetActive = async (id) => {
- await api.setActiveProvider(id);
- setActiveProviderId(id);
+ if (!id) return;
+ const result = await api.setActiveProvider(id).catch(() => null);
+ if (result) setActiveProviderId(id);
};
const handleTest = async (id) => {
diff --git a/server/routes/providers.js b/server/routes/providers.js
index 3f9e344d9e..2490dbdc8f 100644
--- a/server/routes/providers.js
+++ b/server/routes/providers.js
@@ -49,6 +49,20 @@ export function createPortOSProviderRoutes(aiToolkit) {
res.json(sanitizeProvider(provider));
}));
+ // PUT /active must be defined before PUT /:id to avoid the wildcard
+ // catching "active" as a provider ID (which causes 404 "Provider not found")
+ router.put('/active', asyncHandler(async (req, res) => {
+ const { id } = req.body;
+ if (!id) {
+ return res.status(400).json({ error: 'Provider ID required' });
+ }
+ const provider = await providerService.setActiveProvider(id);
+ if (!provider) {
+ return res.status(404).json({ error: 'Provider not found' });
+ }
+ res.json(sanitizeProvider(provider));
+ }));
+
router.get('/samples', asyncHandler(async (req, res) => {
const providers = await providerService.getSampleProviders();
res.json({ providers: providers.map(sanitizeProvider) });