Skip to content

SJS module error being reported as "failed to POST: Internal Server Error #1264

@georgeajit

Description

@georgeajit

So we can address your issue, please include the following:

Version of MarkLogic Java Client API

5.3.0

Version of MarkLogic Server

10.0-5

Java version

JDK 1.8 u261

OS and version

Windows IntelliJ IDE

Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end

'use strict';

var endpointState;          // jsonDocument?
var endpointConstants;      // jsonDocument?
declareUpdate();

const w = fn.head(xdmp.fromJSON(endpointConstants));
const endpt = fn.head(xdmp.fromJSON(endpointState));

const thisBatchStart = endpt.returnIndex;

endpt.returnIndex = endpt.returnIndex + w.max - 1;
fn.error(xs.QName("XDMP-INVALDATE"), "greater than 50");

...
...
let ret = Sequence.from(res)
console.log(ret);
ret;
{
  "endpoint": "/dynamic/fntest/DynamicEgressServicesError/json/DynamicEgressServicesForJsonError.sjs",
  "params": [ {
    "name":     "endpointState",
    "datatype": "jsonDocument",
    "multiple": false,
    "nullable": true
    }, {
    "name":     "session",
    "datatype": "session",
    "multiple": false,
    "nullable": true
    }, {
    "name":     "endpointConstants",
    "datatype": "jsonDocument",
    "multiple": false,
    "nullable": true
    } ],
  "return": {
    "datatype": "jsonDocument",
    "multiple": true,
    "nullable": true
  }
}

...
...
OutputCaller<InputStream> unloadEndpt = OutputCaller.on(dbclient, new FileHandle(new File(ApiConfigDirPath + JsonEgressErrorConfigName + ".api")), new InputStreamHandle());

            IOEndpoint.CallContext callContextArray = unloadEndpt.newCallContext()
                    .withEndpointStateAs(returnIndex)
                    .withEndpointConstantsAs(workParams);

            OutputCaller.BulkOutputCaller<InputStream> outputBulkCaller = unloadEndpt.bulkCaller(callContextArray);
            OutputCaller.BulkOutputCaller.ErrorListener errorListener =
                    (retryCount, throwable, callContext)
                            -> {
                        retryBuf.append(throwable.getMessage());
                        return IOEndpoint.BulkIOEndpointCaller.ErrorDisposition.SKIP_CALL;
                    };

            outputBulkCaller.setOutputListener(record -> {
                        try {
                            ObjectMapper mapper = new ObjectMapper();
                            String s = mapper.readValue(record, ObjectNode.class).toString();
                            batchResults.append(s);
                        } catch (IOException e) {
                            err.append(e.getMessage());
                            e.printStackTrace();
                        }
                    }
            );
            outputBulkCaller.setErrorListener(errorListener);
            outputBulkCaller.awaitCompletion();
            System.out.println("Error buffer is " + retryBuf.toString());
...
...

Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)

Client side error message:

failed to POST at /dynamic/fntest/DynamicEgressServicesError/json/DynamicEgressServicesForJsonError.sjs: Internal Server Error. Server Message: Server did not respond with an expected Error message.

Server side error message:

09:51:47.329 Info: Status 500: greater than 50 (ERROR): fn.error(xs.QName("ERROR"), "greater than 50"); --

The above error is the message from fn.error() call.

Expected output: What specifically did you expect to happen?

Expect server side message to pass through to client code.

Alternatives: What else have you tried, actual/expected?

n/a

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions