Node platform.api: wrong argument order fails silently (callback never fires) · Issue #70 · dreamfactorysoftware/df-script · GitHub
Skip to content

Node platform.api: wrong argument order fails silently (callback never fires) #70

Open

Description

@nicdavidson

platform.api in the Node.js engine fails silently when arguments are in the wrong position. Reproduced on 7.7.0 (df-script dev-develop 4fa09c4).

Repro (Node scripted service, local echo server as target):

// bug form: callback passed in the 3rd (options) slot, like get()
platform.api.delete(path, {marker: 'v1'}, function (body) { /* never runs */ });
// correct forms
platform.api.delete(path, {marker: 'v2'}, {}, function (body) { /* runs */ });
platform.api.delete(path, null, {}, function (body) { /* runs, true DELETE */ });

Observed (bug form):

  • The callback never fires. No error is thrown or logged.
  • The request is sent as POST with x-http-method: DELETE (truthy payload path, src/Engines/NodeJs.php ~243).
  • The callback function is serialized into a bogus headers request header, and the payload body is empty.

Cause: get(path, options, callback) vs post/put/patch/delete(path, payload, options, callback). Called get-style, callback is undefined and http.request(_options, undefined) attaches no response handler.

Fix:

  • In _platform.api.call (and the verb wrappers), throw a clear error when callback is not a function, naming the expected signature, e.g. platform.api.delete(path, payload, options, callback): callback must be a function.
  • Do not serialize non-object options into headers.
  • Same check for the Python engines' get vs write-verb split where it applies.

Docs side: dreamfactorysoftware/df-docs#130.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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