Skip to content

[Bug]: API rejects 'suspend' action type in validateActionData() #248

@bk-ty

Description

@bk-ty

Description

The suspend action type is fully supported at runtime (runJobAction_suspend() in lib/action.js), but the API input validation in validateActionData() (lib/api.js ~line 468) rejects it as an unknown type. This prevents creating or updating events with suspend actions via the API (create_event/v1, update_event/v1), even though they work correctly when configured through the UI.

Steps to Reproduce

curl -X POST http://localhost:3012/api/app/create_event/v1 \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "title": "Test Suspend",
    "enabled": true,
    "category": "general",
    "targets": ["main"],
    "plugin": "shellplug",
    "params": { "script": "echo hi" },
    "actions": [
      { "type": "suspend", "condition": "start", "enabled": true }
    ]
  }'

Expected: Event created successfully.
Actual: Returns error: "Unknown type"

Root Cause

The validateActionData() method in lib/api.js has a switch statement that enumerates recognized action types (email, web_hook, run_event, channel, store, fetch, plugin, disable, delete). The suspend type is missing from this list, so it falls through to the default case which returns "Unknown type".

The runtime engine handles suspend actions correctly — runJobAction_suspend() in lib/action.js exists and works. The validation is simply out of sync with the runtime.

Suggested Fix

Add case 'suspend': to the action type validation switch in lib/api.js:

case 'suspend':
    // suspend action - pauses job for manual approval
break;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions