fix(automations): treat projectId-only requests as project-scoped

Dashboard's Automations page calls GET /api/automations?projectId=X
without &scope=project. The previous resolveAutomationStore() defaulted
scope=undefined to the global store, hiding project-local automations
from the UI list. Fix: prefer project store when projectId is present,
fall through to global only when scope=global is explicit.

Surfaced while wiring the sase changelog auto-publisher — the automation
record existed in the project DB but the UI showed 'No automations yet'.
This commit is contained in:
semih
2026-05-12 07:53:09 +00:00
parent 55832b6ad4
commit 6263a8eb2e

View File

@@ -222,7 +222,7 @@ export function createApiRoutesContext(store: TaskStore, options?: ServerOptions
const projectId = getProjectIdFromRequest(req);
const engineManager = options?.engineManager;
if (scope === "global" || scope === undefined) {
if (scope === "global") {
const defaultStore = options?.automationStore;
if (!defaultStore) {
throw new ApiError(503, "Automation store not available");
@@ -230,6 +230,9 @@ export function createApiRoutesContext(store: TaskStore, options?: ServerOptions
return defaultStore;
}
// scope === "project" OR (scope undefined && projectId present)
// Dashboard sends `?projectId=X` without `&scope=project`; treat that as
// project-scoped to surface per-project automations in the UI list view.
if (projectId && engineManager) {
const engine = engineManager.getEngine(projectId);
if (engine) {