From 2512df7ca1c129dcaa55de0a11022af0054e22c0 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Tue, 15 Dec 2020 19:21:31 +0545 Subject: [PATCH] Prevent loading non-dict vars (#5107) --- dvc/parsing/context.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dvc/parsing/context.py b/dvc/parsing/context.py index 8c941d7dc..67e34d4c1 100644 --- a/dvc/parsing/context.py +++ b/dvc/parsing/context.py @@ -355,6 +355,12 @@ class Context(CtxDict): loader = LOADERS[ext] data = loader(path, tree=tree) + if not isinstance(data, Mapping): + typ = type(data).__name__ + raise ContextError( + f"expected a dictionary, got '{typ}' in file '{file}'" + ) + select_keys = select_keys or [] if select_keys: try: