Skip to content

tooling.destroy() with an array of ids always fails #1815

Open

Description

@SalikLP

Description

conn.tooling.destroy(type, ids) fails with NOT_FOUND: The requested resource does not exist whenever ids is an array, even an array of one element. The same call with a single id string works fine.

Reproduction

const conn = new jsforce.Connection({ instanceUrl, accessToken });

// works: DELETE /services/data/v65.0/tooling/sobjects/Flow/301S800001CkHexIAF
await conn.tooling.destroy('Flow', '301S800001CkHexIAF');

// always fails with "The requested resource does not exist":
await conn.tooling.destroy('Flow', ['301S800001CkHexIAF'], { allOrNone: false });

Root cause

Connection.destroy() routes array input to _destroyMany(), which builds a sObject Collections URL:

// lib/connection.js
async _destroyMany(type, ids, options) {
  ...
  let url = [this._baseUrl(), 'composite', 'sobjects?ids='].join('/') + ids.join(',');

The Tooling class copies destroy / _destroyMany verbatim from Connection.prototype:

// lib/api/tooling.js
const { ..., destroy, _destroySingle, _destroyParallel, _destroyMany, ... } = Connection.prototype;

and its _baseUrl() appends /tooling, so the request becomes:

DELETE /services/data/v65.0/tooling/composite/sobjects?ids=...

The Tooling API has no sObject Collections resource (/composite/sobjects exists only in the regular REST API), so Salesforce returns 404 / The requested resource does not exist. The multi-record code paths for create() and update() are inherited the same way and should hit the same problem.

Expected behavior

Either:

  • Tooling overrides _destroyMany / _createMany / _updateMany to use _destroyParallel-style unitary calls, or batches through the Tooling composite endpoint (POST /services/data/vXX.X/tooling/composite, max 25 subrequests), or
  • the array form throws a clear "not supported by the Tooling API" error instead of a confusing 404.

Workaround

Call destroy per id, or build a Tooling composite request manually:

await conn.requestPost(`/services/data/v${conn.version}/tooling/composite`, {
  allOrNone: false,
  compositeRequest: ids.map((id, i) => ({
    method: 'DELETE',
    url: `/services/data/v${conn.version}/tooling/sobjects/Flow/${id}`,
    referenceId: `ref${i}`,
  })),
});

Activity

  1. petrovicistefan commented on Oct 15, 2026

    @petrovicistefan

    Hi! I'd like to work on this issue if it's still available. I'll reproduce the Tooling API array-input failure and add regression tests. Would you prefer individual Tooling requests or the Tooling composite endpoint?

    I'm also open to B2B development collaborations, joining a team or working alongside other developers. Happy to discuss if there's a fit.

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