Skip to content

Issue with queryAll() function - read forestInfo: cannot process response with 405 status with path #837

@sunnywd

Description

@sunnywd

I encountered a 405 error while running the queryAll() function. If I've overlooked anything, further instructions would be appreciated. Below are the details I've posted on Stack Overflow. Please let me know if any additional information or clarification is needed.

I attempted a simple queryAll() example, which resulted in the following error:

MarkLogicError: read forestInfo: cannot process response with 405 status with path.

Is this function currently operational? Do I need to make any additional configuration or permission changes, or install any extra plugins in the MarkLogic instance?

The MarkLogic documentation references the queryAll() function, and there's an example query on GitHub. When it comes to reading bulk data, is custom data service a more preferred approach?

Here is the list of references I'm aware of, but they haven't been helpful so far:

Below is the simple code example that I got the 405 status error:

const marklogic = require("marklogic");
const connection = require("./settings").connection;
const db = marklogic.createDatabaseClient(connection);
const qb = marklogic.queryBuilder;
const ctsQb = marklogic.ctsQueryBuilder;

const query = qb.where(ctsQb.cts.directoryQuery(["/object/"]));

try {
  db.documents.queryAll(query, {
    onCompletion: (summary) => {
      console.log(summary.urisReadSoFar+' uris were retrieved successfully.');
      console.log(summary.urisFailedToBeRead+' uris failed to be retrieved.');
      console.log('Time taken was '+summary.timeElapsed+' milliseconds.');
    },
  })
} catch (err) {
  console.error("QueryAll Error: ", err);
}

I confirmed the simple cts directory query works in this simpler query example:

const query = qb.where(ctsQb.cts.directoryQuery(["/object/"]));
db.documents.query(query).result(
  (documents) => {
    documents.forEach((doc) => {
      console.log(doc);
    });
    console.log(`${documents.length} uris were retrieved successfully.`);
  },
  (error) => {
    console.log("Error: ", error);
  }
);

Additionally, the REST API access log shows the following entry:

127.0.0.1 - admin [28/Jan/2024:17:57:48 -0500] "POST /v1/internal/forestinfo&database=my-db-dev HTTP/1.1" 405 0 - -

It's a local MarkLogic 11.1.0 instance on a MacBook with an M1 chip, using a developer license. The request was executed with MarkLogic admin user privileges. The database has three forests attached: my-db-dev-1, my-db-dev-2, and my-db-dev-3.

I was able to replicate the same 405 error when I tried queryAll() with a new REST API instance, created following the [MarkLogic's REST API instruction] (developer.marklogic.com/learn/rest).

Marklogic npm module version: "3.3.0"
Node.js v20.9.0
Detailed error message:

ml-examples/node_modules/marklogic/lib/operation.js:231
  return new mlutil.Error(
         ^
MarkLogicError: read forestInfo: cannot process response with 405 status with path: 
    at Operation.makeError (ml-examples/node_modules/marklogic/lib/operation.js:231:10)
    at Operation.isResponseStatusOkay (ml-examples/node_modules/marklogic/lib/responder.js:1040:33)
    at Operation.responseDispatcher (ml-examples/node_modules/marklogic/lib/responder.js:48:29)
    at Operation.retryDispatcher (ml-examples/node_modules/marklogic/lib/requester.js:336:34)
    at ClientRequest.callBackMethod (ml-examples/node_modules/marklogic/lib/mlutil.js:126:17)
    at Object.onceWrapper (node:events:629:26)
    at ClientRequest.emit (node:events:514:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at Socket.socketOnData (node:_http_client:535:22)
Emitted 'error' event on PassThrough instance at:
    at ml-examples/node_modules/marklogic/lib/documents.js:2548:25
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 405
}

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