Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 42 additions & 33 deletions src/common/exportsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface CommonExportData {
interface ReadyExport extends CommonExportData {
exportStatus: "ready";
exportCreatedAt: number;
docsTransformed: number;
}

interface InProgressExport extends CommonExportData {
Expand Down Expand Up @@ -124,7 +125,7 @@ export class ExportsManager extends EventEmitter<ExportsManagerEvents> {
}
}

public async readExport(exportName: string): Promise<string> {
public async readExport(exportName: string): Promise<{ content: string; docsTransformed: number }> {
try {
this.assertIsNotShuttingDown();
exportName = decodeAndNormalize(exportName);
Expand All @@ -137,9 +138,12 @@ export class ExportsManager extends EventEmitter<ExportsManagerEvents> {
throw new Error("Requested export is still being generated. Try again later.");
}

const { exportPath } = exportHandle;
const { exportPath, docsTransformed } = exportHandle;

return fs.readFile(exportPath, { encoding: "utf8", signal: this.shutdownController.signal });
return {
content: await fs.readFile(exportPath, { encoding: "utf8", signal: this.shutdownController.signal }),
docsTransformed,
};
} catch (error) {
this.logger.error({
id: LogId.exportReadError,
Expand Down Expand Up @@ -202,17 +206,15 @@ export class ExportsManager extends EventEmitter<ExportsManagerEvents> {
}): Promise<void> {
try {
let pipeSuccessful = false;
let docsTransformed = 0;
try {
await fs.mkdir(this.exportsDirectoryPath, { recursive: true });
const outputStream = createWriteStream(inProgressExport.exportPath);
await pipeline(
[
input.stream(),
this.docToEJSONStream(this.getEJSONOptionsForFormat(jsonExportFormat)),
outputStream,
],
{ signal: this.shutdownController.signal }
);
const ejsonTransform = this.docToEJSONStream(this.getEJSONOptionsForFormat(jsonExportFormat));
await pipeline([input.stream(), ejsonTransform, outputStream], {
signal: this.shutdownController.signal,
});
docsTransformed = ejsonTransform.docsTransformed;
pipeSuccessful = true;
} catch (error) {
// If the pipeline errors out then we might end up with
Expand All @@ -231,6 +233,7 @@ export class ExportsManager extends EventEmitter<ExportsManagerEvents> {
...inProgressExport,
exportCreatedAt: Date.now(),
exportStatus: "ready",
docsTransformed,
};
this.emit("export-available", inProgressExport.exportURI);
}
Expand All @@ -256,33 +259,39 @@ export class ExportsManager extends EventEmitter<ExportsManagerEvents> {
}
}

private docToEJSONStream(ejsonOptions: EJSONOptions | undefined): Transform {
private docToEJSONStream(ejsonOptions: EJSONOptions | undefined): Transform & { docsTransformed: number } {
let docsTransformed = 0;
return new Transform({
objectMode: true,
transform(chunk: unknown, encoding, callback): void {
try {
const doc = EJSON.stringify(chunk, undefined, undefined, ejsonOptions);
const result = Object.assign(
new Transform({
objectMode: true,
transform(chunk: unknown, encoding, callback): void {
try {
const doc = EJSON.stringify(chunk, undefined, undefined, ejsonOptions);
if (docsTransformed === 0) {
this.push("[" + doc);
} else {
this.push(",\n" + doc);
}
docsTransformed++;
callback();
} catch (err) {
callback(err as Error);
}
},
flush(callback): void {
if (docsTransformed === 0) {
this.push("[" + doc);
this.push("[]");
} else {
this.push(",\n" + doc);
this.push("]");
}
docsTransformed++;
result.docsTransformed = docsTransformed;
callback();
} catch (err) {
callback(err as Error);
}
},
flush(callback): void {
if (docsTransformed === 0) {
this.push("[]");
} else {
this.push("]");
}
callback();
},
});
},
}),
{ docsTransformed }
);

return result;
}

private async cleanupExpiredExports(): Promise<void> {
Expand Down
9 changes: 7 additions & 2 deletions src/resources/common/exportedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { Server } from "../../server.js";
import { LogId } from "../../common/logger.js";
import type { Session } from "../../common/session.js";
import { formatUntrustedData } from "../../tools/tool.js";

export class ExportedData {
private readonly name = "exported-data";
Expand Down Expand Up @@ -95,13 +96,17 @@ export class ExportedData {
throw new Error("Cannot retrieve exported data, exportName not provided.");
}

const content = await this.session.exportsManager.readExport(exportName);
const { content, docsTransformed } = await this.session.exportsManager.readExport(exportName);

const text = formatUntrustedData(`The exported data contains ${docsTransformed} documents.`, content)
.map((t) => t.text)
.join("\n");

return {
contents: [
{
uri: url.href,
text: content,
text,
mimeType: "application/json",
},
],
Expand Down
29 changes: 19 additions & 10 deletions tests/integration/resources/exportedData.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from "path";
import fs from "fs/promises";
import { Long } from "bson";
import type { ObjectId } from "bson";
import { EJSON, Long } from "bson";
import { describe, expect, it, beforeEach, afterAll } from "vitest";
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { defaultTestConfig, resourceChangedNotification, timeout } from "../helpers.js";
import { defaultTestConfig, getDataFromUntrustedContent, resourceChangedNotification, timeout } from "../helpers.js";
import { describeWithMongoDB } from "../tools/mongodb/mongodbHelpers.js";
import { contentWithResourceURILink } from "../tools/mongodb/read/export.test.js";
import type { UserConfig } from "../../../src/lib.js";
Expand All @@ -15,18 +16,17 @@
exportCleanupIntervalMs: 300,
};

const docs = [
{ name: "foo", longNumber: new Long(1234) },
{ name: "bar", bigInt: new Long(123412341234) },
];

describeWithMongoDB(
"exported-data resource",
(integration) => {
beforeEach(async () => {
const mongoClient = integration.mongoClient();
await mongoClient
.db("db")
.collection("coll")
.insertMany([
{ name: "foo", longNumber: new Long(1234) },
{ name: "bar", bigInt: new Long(123412341234) },
]);
await mongoClient.db("db").collection("coll").insertMany(docs);

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (macos-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to autocomplete the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed0d452923b65b090d32') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed0d452923b65b090d32' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (macos-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to read the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed0d452923b65b090d32') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed0d452923b65b090d32' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (macos-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting an expired resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed0d452923b65b090d32') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed0d452923b65b090d32' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (macos-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting non-existent resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed0d452923b65b090d32') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed0d452923b65b090d32' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed0d452923b65b090d32\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (ubuntu-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to autocomplete the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed536250bbda512249ec') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed536250bbda512249ec' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (ubuntu-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to read the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed536250bbda512249ec') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed536250bbda512249ec' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (ubuntu-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting an expired resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed536250bbda512249ec') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed536250bbda512249ec' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (ubuntu-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting non-existent resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ed536250bbda512249ec') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ed536250bbda512249ec' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ed536250bbda512249ec\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (windows-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to autocomplete the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ee0eea5cbd21b38a899c') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ee0eea5cbd21b38a899c' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (windows-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > after requesting a fresh export > should be able to read the resource

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ee0eea5cbd21b38a899c') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ee0eea5cbd21b38a899c' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (windows-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting an expired resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ee0eea5cbd21b38a899c') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ee0eea5cbd21b38a899c' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function

Check failure on line 29 in tests/integration/resources/exportedData.test.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (windows-latest)

tests/integration/resources/exportedData.test.ts > exported-data resource > when requesting non-existent resource > should return an error

MongoBulkWriteError: E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId('68c3ee0eea5cbd21b38a899c') } ❯ OrderedBulkOperation.handleWriteError node_modules/mongodb/src/bulk/common.ts:1207:13 ❯ executeCommands node_modules/mongodb/src/bulk/common.ts:590:19 ❯ node_modules/mongodb/src/bulk/common.ts:1190:16 ❯ MongoClient.withSession node_modules/mongodb/src/mongo_client.ts:936:14 ❯ OrderedBulkOperation.execute node_modules/mongodb/src/bulk/common.ts:1189:14 ❯ Collection.bulkWrite node_modules/mongodb/src/collection.ts:385:12 ❯ Collection.insertMany node_modules/mongodb/src/collection.ts:318:19 ❯ tests/integration/resources/exportedData.test.ts:29:13 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errorLabelSet: { constructor: 'Function<Set>', has: 'Function<has>', add: 'Function<add>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', size: +0, values: 'Function<values>', keys: 'Function<values>', union: 'Function<union>', intersection: 'Function<intersection>', difference: 'Function<difference>', symmetricDifference: 'Function<symmetricDifference>', isSubsetOf: 'Function<isSubsetOf>', isSupersetOf: 'Function<isSupersetOf>', isDisjointFrom: 'Function<isDisjointFrom>' }, errorResponse: { message: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function<div>', equals: 'Function<equals>', eq: 'Function<eq>', getHighBits: 'Function<getHighBits>', getHighBitsUnsigned: 'Function<getHighBitsUnsigned>', getLowBits: 'Function<getLowBits>', getLowBitsUnsigned: 'Function<getLowBitsUnsigned>', getNumBitsAbs: 'Function<getNumBitsAbs>', greaterThan: 'Function<greaterThan>', gt: 'Function<gt>', greaterThanOrEqual: 'Function<greaterThanOrEqual>', gte: 'Function<gte>', ge: 'Function<ge>', isEven: 'Function<isEven>', isNegative: 'Function<isNegative>', isOdd: 'Function<isOdd>', isPositive: 'Function<isPositive>', isZero: 'Function<isZero>', lessThan: 'Function<lessThan>', lt: 'Function<lt>', lessThanOrEqual: 'Function<lessThanOrEqual>', lte: 'Function<lte>', modulo: 'Function<modulo>', mod: 'Function<mod>', rem: 'Function<rem>', multiply: 'Function<multiply>', mul: 'Function<mul>', negate: 'Function<negate>', neg: 'Function<neg>', not: 'Function<not>', notEquals: 'Function<notEquals>', neq: 'Function<neq>', ne: 'Function<ne>', or: 'Function<or>', shiftLeft: 'Function<shiftLeft>', shl: 'Function<shl>', shiftRight: 'Function<shiftRight>', shr: 'Function<shr>', shiftRightUnsigned: 'Function<shiftRightUnsigned>', shr_u: 'Function<shr_u>', shru: 'Function<shru>', subtract: 'Function<subtract>', sub: 'Function<sub>', toInt: 'Function<toInt>', toNumber: 'Function<toNumber>', toBigInt: 'Function<toBigInt>', toBytes: 'Function<toBytes>', toBytesLE: 'Function<toBytesLE>', toBytesBE: 'Function<toBytesBE>', toSigned: 'Function<toSigned>', toString: 'Function<toString>', toUnsigned: 'Function<toUnsigned>', xor: 'Function<xor>', eqz: 'Function<eqz>', le: 'Function<le>', toExtendedJSON: 'Function<toExtendedJSON>', inspect: 'Function<inspect>' }, _id: '68c3ee0eea5cbd21b38a899c' } } ] }, code: 11000, writeErrors: [ { code: 11000, index: +0, errmsg: 'E11000 duplicate key error collection: db.coll index: _id_ dup key: { _id: ObjectId(\'68c3ee0eea5cbd21b38a899c\') }', op: { name: 'foo', longNumber: { low: 1234, high: +0, unsigned: false, constructor: 'Function<Long>', _bsontype: 'Long', __isLong__: true, add: 'Function<add>', and: 'Function<and>', compare: 'Function<compare>', comp: 'Function<comp>', divide: 'Function<divide>', div: 'Function
});

afterAll(async () => {
Expand Down Expand Up @@ -125,7 +125,16 @@
});
expect(response.isError).toBeFalsy();
expect(response.contents[0]?.mimeType).toEqual("application/json");
expect(response.contents[0]?.text).toContain("foo");

expect(response.contents[0]?.text).toContain(`The exported data contains ${docs.length} documents.`);
expect(response.contents[0]?.text).toContain("<untrusted-user-data");
const exportContent = getDataFromUntrustedContent((response.contents[0]?.text as string) || "");
const exportedDocs = EJSON.parse(exportContent) as { name: string; _id: ObjectId }[];
const expectedDocs = docs as unknown as { name: string; _id: ObjectId }[];
expect(exportedDocs[0]?.name).toEqual(expectedDocs[0]?.name);
expect(exportedDocs[0]?._id).toEqual(expectedDocs[0]?._id);
expect(exportedDocs[1]?.name).toEqual(expectedDocs[1]?.name);
expect(exportedDocs[1]?._id).toEqual(expectedDocs[1]?._id);
});

it("should be able to autocomplete the resource", async () => {
Expand Down
Loading