fix(routines,automations): list endpoints must not short-circuit on missing global store
The early-return when options?.routineStore (or automationStore) is falsy was hiding per-project records from the dashboard whenever the Fusion daemon had no global store wired. Replace with a try/catch around resolveRoutineStore so project-only setups surface records and the [] fallback only triggers when neither global nor project store exists. This is the second half of the previous fix — resolveRoutineStore now prefers project, but the GET handler was bailing out before reaching it.
This commit is contained in:
@@ -1836,14 +1836,21 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
|
||||
// GET /automations — list all scheduled tasks (optionally filtered by scope)
|
||||
router.get("/automations", async (req: Request, res: Response) => {
|
||||
// Return empty array when no store available (legacy backward-compatible behavior)
|
||||
if (!options?.automationStore) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
try {
|
||||
const scope = parseScopeParam(req);
|
||||
const automationStore = resolveAutomationStore(req, scope);
|
||||
// Resolve store (project-aware): only short-circuit to [] when neither
|
||||
// global nor a project store is wired. The previous early-return on
|
||||
// !options?.automationStore hid per-project automations from the
|
||||
// dashboard even when an engine-backed project store existed.
|
||||
let automationStore;
|
||||
try {
|
||||
automationStore = resolveAutomationStore(req, scope);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.status === 503) {
|
||||
return res.json([]);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Get all schedules and filter by scope if specified
|
||||
// When scope is omitted, return all schedules (legacy behavior)
|
||||
@@ -2157,14 +2164,21 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
|
||||
// GET /routines — list all routines (optionally filtered by scope)
|
||||
router.get("/routines", async (req: Request, res: Response) => {
|
||||
// Return empty array when no store available (legacy backward-compatible behavior)
|
||||
if (!options?.routineStore) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
try {
|
||||
const scope = parseScopeParam(req);
|
||||
const routineStore = resolveRoutineStore(req, scope);
|
||||
// Resolve store (project-aware): falls through to global when no project
|
||||
// scope is requested. Early-return [] only when NO store is wired at all
|
||||
// (preserves legacy behavior); project-only setups must not short-circuit
|
||||
// here, otherwise the dashboard never sees its per-project routines.
|
||||
let routineStore;
|
||||
try {
|
||||
routineStore = resolveRoutineStore(req, scope);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.status === 503) {
|
||||
return res.json([]);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Get all routines and filter by scope if specified
|
||||
// When scope is omitted, return all routines (legacy behavior)
|
||||
|
||||
Reference in New Issue
Block a user