Skip to content

Commit 121e453

Browse files
authored
Merge pull request #704 from maykinmedia/fix/missing-error-code
🐛 [#595] Fix missing severity key
2 parents eb3606b + 137184f commit 121e453

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

backend/src/openarchiefbeheer/config/api/views.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ class HealthCheckView(APIView):
111111
"message": serializers.CharField(
112112
help_text="A human readable error message."
113113
),
114-
"severity": serializers.CharField(
115-
help_text="Whether this is an error, warning or info."
114+
"severity": serializers.ChoiceField(
115+
help_text="Whether this is an error, warning or info.",
116+
choices=["error", "warning", "info"],
116117
),
117118
"field": serializers.CharField(
118119
help_text="The field of a model that is not properly configured. Can be empty.",

backend/src/openarchiefbeheer/config/health_checks.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TypedDict
1+
from typing import Literal, TypedDict
22

33
from django.utils.translation import gettext_lazy as _
44

@@ -8,12 +8,12 @@
88
from .models import APIConfig, ArchiveConfig
99

1010

11-
class HealthCheckError(TypedDict):
11+
class HealthCheckError(TypedDict, total=False):
1212
model: str
1313
code: str
1414
message: str
15-
severity: str = "error"
16-
field: str = ""
15+
severity: Literal["error", "warning", "info"]
16+
field: str
1717

1818

1919
class HealthCheckResponse(TypedDict):
@@ -26,46 +26,55 @@ class HealthCheckResponse(TypedDict):
2626
model="zgw_consumers.models.Service",
2727
code="MISSING_ZRC_SERVICE",
2828
message=_("ZRC service is missing."),
29+
severity="error",
2930
),
3031
"MISSING_DRC_SERVICE": HealthCheckError(
3132
model="zgw_consumers.models.Service",
3233
code="MISSING_DRC_SERVICE",
3334
message=_("DRC service is missing."),
35+
severity="error",
3436
),
3537
"MISSING_BRC_SERVICE": HealthCheckError(
3638
model="zgw_consumers.models.Service",
3739
code="MISSING_BRC_SERVICE",
3840
message=_("BRC service is missing."),
41+
severity="error",
3942
),
4043
"MISSING_ZTC_SERVICE": HealthCheckError(
4144
model="zgw_consumers.models.Service",
4245
code="MISSING_ZTC_SERVICE",
4346
message=_("ZTC service is missing."),
47+
severity="error",
4448
),
4549
"IMPROPERLY_CONFIGURED_ZRC_SERVICE": HealthCheckError(
4650
model="zgw_consumers.models.Service",
4751
code="IMPROPERLY_CONFIGURED_ZRC_SERVICE",
4852
message=_("The ZRC service is improperly configured."),
53+
severity="error",
4954
),
5055
"IMPROPERLY_CONFIGURED_DRC_SERVICE": HealthCheckError(
5156
model="zgw_consumers.models.Service",
5257
code="IMPROPERLY_CONFIGURED_DRC_SERVICE",
5358
message=_("The DRC service is improperly configured."),
59+
severity="error",
5460
),
5561
"IMPROPERLY_CONFIGURED_BRC_SERVICE": HealthCheckError(
5662
model="zgw_consumers.models.Service",
5763
code="IMPROPERLY_CONFIGURED_BRC_SERVICE",
5864
message=_("The BRC service is improperly configured."),
65+
severity="error",
5966
),
6067
"IMPROPERLY_CONFIGURED_ZTC_SERVICE": HealthCheckError(
6168
model="zgw_consumers.models.Service",
6269
code="IMPROPERLY_CONFIGURED_ZTC_SERVICE",
6370
message=_("The ZTC service is improperly configured."),
71+
severity="error",
6472
),
6573
"IMPROPERLY_CONFIGURED_SELECTIELIJST_SERVICE": HealthCheckError(
6674
model="zgw_consumers.models.Service",
6775
code="IMPROPERLY_CONFIGURED_SELECTIELIJST_SERVICE",
6876
message=_("The selectielijst service is improperly configured."),
77+
severity="error",
6978
),
7079
}
7180

@@ -75,6 +84,7 @@ class HealthCheckResponse(TypedDict):
7584
field="selectielijst_api_service",
7685
code="MISSING_SELECTIELIJST_API",
7786
message=_("No selectielijst service selected in the API configuration."),
87+
severity="error",
7888
)
7989
}
8090

@@ -84,18 +94,21 @@ class HealthCheckResponse(TypedDict):
8494
field="bronorganisatie",
8595
code="MISSING_BRONORGANISATIE",
8696
message=_("No source organisation for the destruction report case configured."),
97+
severity="error",
8798
),
8899
"MISSING_ZAAKTYPE": HealthCheckError(
89100
model="openarchiefbeheer.config.ArchiveConfig",
90101
field="zaaktype",
91102
code="MISSING_ZAAKTYPE",
92103
message=_("No zaaktype for the destruction report case configured."),
104+
severity="error",
93105
),
94106
"MISSING_SELECTIELIJSTKLASSE": HealthCheckError(
95107
model="openarchiefbeheer.config.ArchiveConfig",
96108
field="selectielijstklasse",
97109
code="MISSING_SELECTIELIJSTKLASSE",
98110
message=_("No selectielijstklasse for the destruction report case configured."),
111+
severity="error",
99112
),
100113
"MISSING_INFORMATIEOBJECTTYPE": HealthCheckError(
101114
model="openarchiefbeheer.config.ArchiveConfig",
@@ -104,6 +117,7 @@ class HealthCheckResponse(TypedDict):
104117
message=_(
105118
"No informatieobjecttype for the destruction report document configured."
106119
),
120+
severity="error",
107121
),
108122
}
109123

0 commit comments

Comments
 (0)