summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-06-10 23:50:23 +0200
committerGitHub <noreply@github.com>2021-06-10 23:50:23 +0200
commit600a2c174f5fe274728b98b38d49f009946bcc4f (patch)
treede9bc431060437fe259115c920c67389a0cccb5f /gitlab
parent161bb0bf1684374ed01c4e3bc8ebc2f5afe7546b (diff)
parentc7bcc25a361f9df440f9c972672e5eec3b057625 (diff)
downloadgitlab-600a2c174f5fe274728b98b38d49f009946bcc4f.tar.gz
Merge pull request #1487 from JohnVillalovos/jlvillal/check_attrs
fix: catch invalid type used to initialize RESTObject
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/base.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 689b68c..bea1901 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -20,6 +20,7 @@ from types import ModuleType
from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type
from gitlab import types as g_types
+from gitlab.exceptions import GitlabParsingError
from .client import Gitlab, GitlabList
@@ -51,6 +52,12 @@ class RESTObject(object):
manager: "RESTManager"
def __init__(self, manager: "RESTManager", attrs: Dict[str, Any]) -> None:
+ if not isinstance(attrs, dict):
+ raise GitlabParsingError(
+ "Attempted to initialize RESTObject with a non-dictionary value: "
+ "{!r}\nThis likely indicates an incorrect or malformed server "
+ "response.".format(attrs)
+ )
self.__dict__.update(
{
"manager": manager,