From db6ddf8ed9553878f723353ad576d7a12c223bc0 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Fri, 9 Jul 2021 12:41:44 +0200 Subject: [PATCH] TMSS-745: use safe get --- SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index ac7c7c88d14..3214f5e3351 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -228,7 +228,7 @@ class SchedulingUnitObservingStrategyTemplate(NamedVersionedCommon): template_doc = deepcopy(self.template) # loop over all tasks, and add the defaults to each task given the task's specifications_template - for task_name, task_doc in list(template_doc['tasks'].items()): + for task_name, task_doc in list(template_doc.get('tasks',{}).items()): task_specifications_template = TaskTemplate.objects.get(name=task_doc['specifications_template']) template_doc['tasks'][task_name] = add_defaults_to_json_object_for_schema(task_doc, task_specifications_template.schema, cache=TemplateSchemaMixin._schema_cache, max_cache_age=TemplateSchemaMixin._MAX_SCHEMA_CACHE_AGE) @@ -244,7 +244,7 @@ class SchedulingUnitObservingStrategyTemplate(NamedVersionedCommon): @property def template_doc_with_just_the_parameters(self) -> dict: - parameter_pointers = sum([p['refs'] for p in self.template['parameters']], []) + parameter_pointers = sum([p['refs'] for p in self.template.get('parameters',[])], []) template_doc = self.template_doc_complete_with_defaults template_doc = subdict_of_pointer_items(template_doc, parameter_pointers) -- GitLab