diff --git a/boefjes/boefjes/job_handler.py b/boefjes/boefjes/job_handler.py index 3de61485a30..8d65429cf89 100644 --- a/boefjes/boefjes/job_handler.py +++ b/boefjes/boefjes/job_handler.py @@ -1,3 +1,4 @@ +import json import os import traceback from collections.abc import Callable @@ -131,22 +132,35 @@ def handle(self, boefje_meta: BoefjeMeta) -> None: boefje_meta.arguments["input"] = ooi.serialize() + boefje_results: list[tuple[set, bytes | str]] = [] boefje_meta.runnable_hash = plugin.runnable_hash - boefje_meta.environment = get_environment_settings(boefje_meta, plugin.boefje_schema) - logger.info("Starting boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id)) + try: + logger.info("Getting environment settings for boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id)) + boefje_meta.environment = get_environment_settings(boefje_meta, plugin.boefje_schema) - boefje_meta.started_at = datetime.now(timezone.utc) + logger.info("Starting boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id)) + boefje_meta.started_at = datetime.now(timezone.utc) + boefje_results = self.job_runner.run(boefje_meta, boefje_meta.environment) - boefje_results: list[tuple[set, bytes | str]] = [] + except SettingsNotConformingToSchema: + logger.exception( + "Error running boefje due to settings/schema mismatch %s[%s]", + boefje_meta.boefje.id, + str(boefje_meta.id), + ) + boefje_results = [({"error/boefje"}, "Error running boefje (%s) due to settings/schema mismatch: %s" % ( + boefje_meta.id, json.dumps(plugin.boefje_schema) + ))] + + raise - try: - boefje_results = self.job_runner.run(boefje_meta, boefje_meta.environment) except: logger.exception("Error running boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id)) boefje_results = [({"error/boefje"}, traceback.format_exc())] raise + finally: boefje_meta.ended_at = datetime.now(timezone.utc) logger.info("Saving to Bytes for boefje %s[%s]", boefje_meta.boefje.id, str(boefje_meta.id))