Skip to content

Core ‐ Agent update‐task

Bohdan Karpenko edited this page Apr 2, 2026 · 1 revision

This handler updates an existing task in the system. It validates input data, applies changes in the database, and returns the updated task or an error.


Update Task Request

Request format

{
    "type": "request",
    "action": "update-task",
    "id": 1,
    "data": {
        "id": 123,
        "name": "Task Name",
        "description": "Task Description",
        "install_script": "install.sh",
        "run_script": "run.sh",
        "delete_script": "delete.sh",
        "restart_policy": "always"
    }
}

Fields

  • type: must be "request"

  • action: must be "update-task"

  • id: request identifier (mirrored in the response)

  • data: object containing task fields:

    • id — integer, task ID to update

    • name — string, new task name

    • description — string, new task description

    • install_script — string, path or content of install script

    • run_script — string, path or content of run script

    • delete_script — string, path or content of delete script

    • restart_policy — enum, one of:

      • "no" — do not restart
      • "always" — always restart
      • "on-failure" — restart only on failure

Behavior

  • Validates that data exists and can be parsed into UpdateTaskDTO
  • Updates task in the database by ID
  • Returns the updated task in the response under data.task if successful

Successful Response

{
    "type": "response",
    "id": 1,
    "status": "ok",
    "code": 200,
    "message": "Successfully updated task.",
    "data": {
        "task": {
            "id": 123,
            "core_id": 45,
            "name": "Task Name",
            "description": "Task Description",
            "install_script": "install.sh",
            "run_script": "run.sh",
            "delete_script": "delete.sh",
            "restart_policy": "always",
            "status": "starting"
        }
    }
}

Error Responses

Missing data

{
    "type": "response",
    "id": 1,
    "status": "error",
    "code": 400,
    "message": "Missing data"
}

Invalid data structure

{
    "type": "response",
    "id": 1,
    "status": "error",
    "code": 400,
    "message": "Invalid update-task request"
}

Failed database update

{
    "type": "response",
    "id": 1,
    "status": "error",
    "code": 400,
    "message": "Failed to update task"
}

Status Enum

  • "ok" — task successfully updated
  • "error" — request failed

Notes

  • The id in the response matches the request id.
  • The restart_policy must be one of "no", "always", "on-failure".
  • If the task does not exist or the database update fails, an error response is returned.
  • data.task contains the full task object after update.

Clone this wiki locally