{"record":{"id":"6ccc5fd963a2c94d","repo":"Mintplex-Labs/anything-llm","slug":"cannot-enable-maximum-of-activation-limit-acti","errorCode":null,"errorMessage":"Cannot enable: maximum of ${activation.limit} active scheduled jobs reached. Disable another job first.","messagePattern":"Cannot enable: maximum of (.+?) active scheduled jobs reached\\. Disable another job first\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/scheduledJobs.js","lineNumber":250,"sourceCode":"          if (!ScheduledJob.isValidCron(schedule)) {\n            return response\n              .status(400)\n              .json({ job: null, error: \"Invalid cron expression\" });\n          }\n          updates.schedule = String(schedule).trim();\n        }\n\n        // If this update would activate the job, enforce the active-jobs cap.\n        // We pass excludeId so a re-save of an already-enabled job is not\n        // double-counted against the limit.\n        if (updates.enabled === true) {\n          const activation = await ScheduledJob.canActivate({\n            excludeId: Number(request.params.id),\n          });\n          if (!activation.allowed) {\n            return response.status(400).json({\n              job: null,\n              error: `Cannot enable: maximum of ${activation.limit} active scheduled jobs reached. Disable another job first.`,\n            });\n          }\n        }\n\n        const { job, error } = await ScheduledJob.update(\n          Number(request.params.id),\n          updates\n        );\n\n        if (error) {\n          return response.status(400).json({ job: null, error });\n        }\n\n        await backgroundService.syncScheduledJob(job.id);\n\n        return response.status(200).json({ job, error: null });\n      } catch (e) {\n        console.error(e.message, e);","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/scheduledJobs.js#L232-L268","documentation":"400 from PUT /api/scheduled-jobs/:id. Setting enabled:true is treated as an activation; before updating, the handler calls ScheduledJob.canActivate({excludeId: id}) which counts all *other* enabled jobs and rejects the update when that count has reached ScheduledJob.MAX_ACTIVE. The excludeId prevents a plain re-save of an already-enabled job from double-counting itself.","triggerScenarios":"PUT /api/scheduled-jobs/5 with {\"enabled\":true} while MAX_ACTIVE other jobs are already enabled. Fires even when the same PUT also edits name/prompt/schedule of a disabled job.","commonSituations":"Bulk scripts that re-enable every job after editing; deployments that set MAX_ACTIVE to bound scheduler load; assuming the cap applies to total jobs rather than enabled jobs.","solutions":["Disable another enabled job first (or via the same bulk pass, stage disables before enables), then retry the update","Keep rarely-used jobs disabled and enable them on demand","Raise or clear ScheduledJob.MAX_ACTIVE in server/models/scheduledJob.js if the cap is inappropriate — no env knob exists yet"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before enabling via PUT, confirm a slot is free\nconst { jobs } = await api.get('/scheduled-jobs');\nconst otherEnabled = jobs.filter(j => j.enabled && j.id !== targetId).length;\nif (MAX_ACTIVE !== null && otherEnabled >= MAX_ACTIVE) {\n  await api.put(`/scheduled-jobs/${pickDisposable(jobs, targetId).id}`, { enabled: false });\n}\nawait api.put(`/scheduled-jobs/${targetId}`, { enabled: true });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In bulk edits, stage disables before enables so the cap is never transiently exceeded","Surface enabled-count vs cap in the UI","Remember a re-save of an already-enabled job is excluded (excludeId) and safe"],"tags":["scheduled-jobs","capacity","api","state-transition"],"backgroundTag":"resource-limit-reached","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}