|
try { |
|
const requesterOrg = await repo.findOneByShortName(requesterOrgShortName, {}, returnLegacyFormat) |
|
const requesterOrgIdentifier = identifierIsUUID ? requesterOrg.UUID : requesterOrgShortName |
|
const isSecretariat = await repo.isSecretariat(requesterOrg, {}, returnLegacyFormat) |
|
|
|
if (requesterOrgIdentifier !== identifier && !isSecretariat) { |
|
logger.info({ uuid: req.ctx.uuid, message: identifier + ' organization can only be viewed by the users of the same organization or the Secretariat.' }) |
|
return res.status(403).json(error.notSameOrgOrSecretariat()) |
|
} |
|
|
|
returnValue = await repo.getOrg(identifier, identifierIsUUID, {}, returnLegacyFormat) |
|
} catch (error) { |
|
// Handle the specific error thrown by BaseOrgRepository.createOrg |
|
if (error.message && error.message.includes('Unknown Org type requested')) { |
|
return res.status(400).json({ message: error.message }) |
|
} |
|
} |
|
if (!returnValue) { // an empty result can only happen if the requestor is the Secretariat |
|
logger.info({ uuid: req.ctx.uuid, message: identifier + ' organization does not exist.' }) |
|
return res.status(404).json(error.orgDne(identifier, 'identifier', 'path')) |
|
} |
There are a few conditions within the try block, including MongoNetworkError, that could cause execution of the
if (!returnValue) block, but all of them are reported as "organization does not exist" even when a 500 error would be correct.
cve-services/src/controller/org.controller/org.controller.js
Lines 62 to 82 in 15238d1
There are a few conditions within the try block, including MongoNetworkError, that could cause execution of the
if (!returnValue)block, but all of them are reported as "organization does not exist" even when a 500 error would be correct.