mirror of https://gitee.com/bigwinds/arangodb
Fix TypeError for invalid manifests (3.4) (#7603)
* Fix TypeError for invalid manifests * Remove unnecessary wrap * Update CHANGELOG
This commit is contained in:
parent
8557fdaf22
commit
da4179af47
|
@ -1,6 +1,9 @@
|
||||||
v3.4.1 (XXXX-XX-XX)
|
v3.4.1 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* fixed TypeError being thrown instead of validation errors when Foxx manifest
|
||||||
|
validation fails
|
||||||
|
|
||||||
* make AQL REMOVE operations use less memory with the RocksDB storage engine
|
* make AQL REMOVE operations use less memory with the RocksDB storage engine
|
||||||
|
|
||||||
the previous implementation of batch removals read everything to remove into
|
the previous implementation of batch removals read everything to remove into
|
||||||
|
|
|
@ -5,9 +5,15 @@ const joi = require('joi');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const joinPath = require('path').join;
|
const joinPath = require('path').join;
|
||||||
const arangodb = require('@arangodb');
|
const {
|
||||||
const ArangoError = arangodb.ArangoError;
|
plainServerVersion,
|
||||||
const errors = arangodb.errors;
|
ArangoError,
|
||||||
|
errors: {
|
||||||
|
ERROR_INVALID_SERVICE_MANIFEST,
|
||||||
|
ERROR_SERVICE_MANIFEST_NOT_FOUND,
|
||||||
|
ERROR_MALFORMED_MANIFEST_FILE
|
||||||
|
}
|
||||||
|
} = require('@arangodb');
|
||||||
const il = require('@arangodb/util').inline;
|
const il = require('@arangodb/util').inline;
|
||||||
|
|
||||||
const CANONICAL_SCHEMA = 'http://json.schemastore.org/foxx-manifest';
|
const CANONICAL_SCHEMA = 'http://json.schemastore.org/foxx-manifest';
|
||||||
|
@ -161,7 +167,7 @@ const manifestSchema = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkManifest (inputManifest, mount, complainAboutVersionMismatches) {
|
function checkManifest (inputManifest, mount, complainAboutVersionMismatches) {
|
||||||
const serverVersion = arangodb.plainServerVersion();
|
const serverVersion = plainServerVersion();
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const manifest = {};
|
const manifest = {};
|
||||||
let legacy = false;
|
let legacy = false;
|
||||||
|
@ -317,9 +323,9 @@ function checkManifest (inputManifest, mount, complainAboutVersionMismatches) {
|
||||||
console.errorLines(error);
|
console.errorLines(error);
|
||||||
}
|
}
|
||||||
throw new ArangoError({
|
throw new ArangoError({
|
||||||
errorNum: errors.ERROR_INVALID_SERVICE_MANIFEST.code,
|
errorNum: ERROR_INVALID_SERVICE_MANIFEST.code,
|
||||||
errorMessage: dd`
|
errorMessage: dd`
|
||||||
${errors.ERROR_INVALID_SERVICE_MANIFEST.message}
|
${ERROR_INVALID_SERVICE_MANIFEST.message}
|
||||||
Manifest for service at "${mount}":
|
Manifest for service at "${mount}":
|
||||||
${errors.join('\n')}
|
${errors.join('\n')}
|
||||||
`
|
`
|
||||||
|
@ -359,9 +365,9 @@ function validateManifestFile (filename, mount, complainAboutVersionMismatches)
|
||||||
let mf;
|
let mf;
|
||||||
if (!fs.exists(filename)) {
|
if (!fs.exists(filename)) {
|
||||||
throw new ArangoError({
|
throw new ArangoError({
|
||||||
errorNum: errors.ERROR_SERVICE_MANIFEST_NOT_FOUND.code,
|
errorNum: ERROR_SERVICE_MANIFEST_NOT_FOUND.code,
|
||||||
errorMessage: dd`
|
errorMessage: dd`
|
||||||
${errors.ERROR_SERVICE_MANIFEST_NOT_FOUND.message}
|
${ERROR_SERVICE_MANIFEST_NOT_FOUND.message}
|
||||||
File: ${filename}
|
File: ${filename}
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
@ -371,27 +377,15 @@ function validateManifestFile (filename, mount, complainAboutVersionMismatches)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Object.assign(
|
throw Object.assign(
|
||||||
new ArangoError({
|
new ArangoError({
|
||||||
errorNum: errors.ERROR_MALFORMED_MANIFEST_FILE.code,
|
errorNum: ERROR_MALFORMED_MANIFEST_FILE.code,
|
||||||
errorMessage: dd`
|
errorMessage: dd`
|
||||||
${errors.ERROR_MALFORMED_MANIFEST_FILE.message}
|
${ERROR_MALFORMED_MANIFEST_FILE.message}
|
||||||
File: ${filename}
|
File: ${filename}
|
||||||
`
|
`
|
||||||
}), {cause: e}
|
}), {cause: e}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
mf = checkManifest(mf, mount, complainAboutVersionMismatches);
|
mf = checkManifest(mf, mount, complainAboutVersionMismatches);
|
||||||
} catch (e) {
|
|
||||||
throw Object.assign(
|
|
||||||
new ArangoError({
|
|
||||||
errorNum: errors.ERROR_INVALID_SERVICE_MANIFEST.code,
|
|
||||||
errorMessage: dd`
|
|
||||||
${errors.ERROR_INVALID_SERVICE_MANIFEST.message}
|
|
||||||
File: ${filename}
|
|
||||||
`
|
|
||||||
}), {cause: e}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return mf;
|
return mf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue