From 59cafb5493abda238ca086f97044adb57f9a515f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 18 Mar 2026 21:36:45 +0100 Subject: [PATCH 1/3] add docs for the scheduler cancel endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../backend-system/core-services/scheduler.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/backend-system/core-services/scheduler.md b/docs/backend-system/core-services/scheduler.md index 55cd23d989..1e56f4903a 100644 --- a/docs/backend-system/core-services/scheduler.md +++ b/docs/backend-system/core-services/scheduler.md @@ -156,6 +156,35 @@ Responds with - `404 Not Found` if there was no such registered task for this plugin - `409 Conflict` if the task was already in a running state +### `POST /.backstage/scheduler/v1/tasks//cancel` + +Cancels the running task with the given task ID. + +For example, to cancel a specific Catalog task: + +```bash +curl -X POST "https:///api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider:refresh/cancel" +``` + +A working example would be: + +```bash +curl -X POST "https://demo.backstage.io/api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider:refresh/cancel" +``` + +Note that there can still be an additional small delay before a worker discovers +that the task is cancelled. This can take up to a few seconds. Note also that it +is up to the task implementation to properly react to the abort signal that was +passed in to it. + +The request has no body. + +Responds with + +- `200 OK` if successful +- `404 Not Found` if there was no such registered task for this plugin +- `409 Conflict` if the task was not in a running state + ## Testing The `@backstage/backend-test-utils` package provides `mockServices.scheduler`, which provides a mocked implementation of the scheduler service that can be used in tests. This mocked implementation is used by default in `startTestBackend`, and it will immediately run any registered tasks on startup as long as they're not configured to run manually or with an initial delay. From 1917f7cd63cda631e835fa83d03c3e09e99aee48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 18 Mar 2026 21:45:01 +0100 Subject: [PATCH 2/3] Potential fix for pull request finding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fredrik Adelöw --- docs/backend-system/core-services/scheduler.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/core-services/scheduler.md b/docs/backend-system/core-services/scheduler.md index 1e56f4903a..41dcec17b5 100644 --- a/docs/backend-system/core-services/scheduler.md +++ b/docs/backend-system/core-services/scheduler.md @@ -175,7 +175,7 @@ curl -X POST "https://demo.backstage.io/api/catalog/.backstage/scheduler/v1/task Note that there can still be an additional small delay before a worker discovers that the task is cancelled. This can take up to a few seconds. Note also that it is up to the task implementation to properly react to the abort signal that was -passed in to it. +passed into it. The request has no body. From 13be681f39c9997c4d80067d596a152cd1316a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 18 Mar 2026 21:45:21 +0100 Subject: [PATCH 3/3] Potential fix for pull request finding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fredrik Adelöw --- docs/backend-system/core-services/scheduler.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/backend-system/core-services/scheduler.md b/docs/backend-system/core-services/scheduler.md index 41dcec17b5..97a807982e 100644 --- a/docs/backend-system/core-services/scheduler.md +++ b/docs/backend-system/core-services/scheduler.md @@ -160,16 +160,20 @@ Responds with Cancels the running task with the given task ID. +Note that `` must be URL-encoded so that it remains a single path segment +in the URL (for example by using `encodeURIComponent` in JavaScript or standard +percent-encoding). + For example, to cancel a specific Catalog task: ```bash -curl -X POST "https:///api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider:refresh/cancel" +curl -X POST "https:///api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider%3Arefresh/cancel" ``` A working example would be: ```bash -curl -X POST "https://demo.backstage.io/api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider:refresh/cancel" +curl -X POST "https://demo.backstage.io/api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider%3Arefresh/cancel" ``` Note that there can still be an additional small delay before a worker discovers