in functions/index.js [109:142]
async function revalidateAndGetErrorFields(pubSubMessage, rawPing, error) {
if (error) {
// Glean ping from unreleased or development app - let's validate against Glean schema
const validator = await schemaValidator;
const validate = validator.validator;
const schemaVersion = validator.schemaVersion;
let errorMessage = null;
let valid = false;
try {
valid = validate(JSON.parse(rawPing));
errorMessage = JSON.stringify(validate.errors);
} catch (e) {
errorMessage = e.toString();
}
return valid ? {
warning: 'JSON_VALIDATION_IN_DEBUG_VIEW',
debugViewSchemaVersion: schemaVersion,
} : {
error: true,
errorType: 'JSON_VALIDATION_ERROR_DEBUG_VIEW',
errorMessage: errorMessage,
debugViewSchemaVersion: schemaVersion,
};
} else {
return error ? {
error: true,
errorType: pubSubMessage.attributes.error_type,
errorMessage: pubSubMessage.attributes.error_message,
} : {};
}
}