Skip to content

bug(instances): POST /instances/{id}/restart returns "gupshupCallbackUrl is required" even when the column is populated #692

@vasconceloscezar

Description

@vasconceloscezar

Problem

POST /api/v2/instances/{id}/restart on a gupshup channel instance always returns:

{"error":{"code":"RESTART_FAILED","message":"Failed to restart: gupshupCallbackUrl is required"}}

…even when gupshup_callback_url is fully populated in the DB row and GET /instances/{id} returns the URL correctly. The restart endpoint appears to validate against the plugin's connectionOptions (which is empty/partial after the instance is already connected) instead of reading from the persisted instance row.

Repro

# 1. Confirm callback URL is set on the row
curl -s -H "x-api-key: <KEY>" \
  "https://<OMNI_HOST>/api/v2/instances/<INSTANCE_ID>" | jq '.data.gupshupCallbackUrl'
# -> "https://notifications.gupshup.io/notifications/callback/service/ipaas/project/<PROJ>/integration/<INT>"

# 2. Try restart
curl -s -i -X POST -H "x-api-key: <KEY>" \
  "https://<OMNI_HOST>/api/v2/instances/<INSTANCE_ID>/restart"
# -> HTTP/2 200
# -> {"error":{"code":"RESTART_FAILED","message":"Failed to restart: gupshupCallbackUrl is required"}}

Workaround

disconnect + connect works and triggers a full plugin re-init (the plugin reads from the row on reconnect):

curl -X POST -H "x-api-key: <KEY>" .../instances/<INSTANCE_ID>/disconnect   # {"success":true}
curl -X POST -H "x-api-key: <KEY>" .../instances/<INSTANCE_ID>/connect -d '{}'
# -> {"data":{"status":"connecting","message":"Connection initiated"}}

After reconnect, GET /status returns state: connected and the plugin picks up any fields PATCHed in the meantime (e.g. gupshupAuthToken, gupshupEventId).

Suspected cause

restartInstance() probably calls plugin.connect(connectionOptions) where connectionOptions is what was passed to the original /connect request (often {} for gupshup, since channel-specific config lives on the instance row). Need to hydrate connectionOptions from the persisted instance row before re-invoking the plugin, or change the plugin contract so restart reads directly from the row.

Environment

  • omni server 2.260531.5
  • channel gupshup (Custom Integration variant)
  • HML deployment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions