Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sunnywd opened this issue Feb 2, 2024 · 6 comments

Comments

@sunnywd
Copy link

sunnywd commented Feb 2, 2024

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
}
@BillFarber
Copy link
Contributor

Hello sunnywd, I'm sorry you're having trouble using our Node client.

I was able to reproduce your issue. Something I found was that the problem only occurs when the "database" property is set in the connection properties, like the following.

const connection = {
host: "localhost",
port: 8015,
user: "admin",
password: "admin",
database: "unittest-nodeapi",
authType: "DIGEST"
};

If the "database" property is not set, then the code works (once I changed occurrences of "summary" to "response" in your example). Unfortunately, that is only useful when the appserver for the port is assigned to the database you wish to query, but perhaps you can use that as a workaround for the time-being.

At this point, I believe this is a bug in the Node client and we will need to add it to our backlog and prioritize it.

Phil

@BillFarber
Copy link
Contributor

I've looked into this a little more and it's definitely a bug in the Node client. I'll get to work on this immediately and hopefully we will have a patch release soon.

In the meantime, the work-around is to not have the "database" property in the connection settings and to use a REST port with the correct database assigned.

@sunnywd
Copy link
Author

sunnywd commented Feb 2, 2024

Thank you for the prompt response. Indeed, the query functioned correctly after I removed 'database' from the connection configuration.

@anu3990
Copy link
Contributor

anu3990 commented Feb 2, 2024

@sunnywd Thank you for confirming.! We will have a release soon. Request you to update the stackoverflow as well. Thanks.!

@BillFarber
Copy link
Contributor

Hi @sunnywd, we have released a new patch version of the client, version 3.3.1, with a fix for this bug.

Thank you for taking the time for reporting the bug!

@sunnywd
Copy link
Author

sunnywd commented Feb 4, 2024

Thanks for the quick turnaround.

@sunnywd sunnywd closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants