Skip to content

Commit 3a3154b

Browse files
authored
Allow coercion of numbers to strings in BugzillaWebhookEventChange (#794)
1 parent cd96b71 commit 3a3154b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

jbi/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ class BugzillaWebhookUser(BaseModel):
175175
class BugzillaWebhookEventChange(BaseModel):
176176
"""Bugzilla Change Object"""
177177

178+
model_config = ConfigDict(coerce_numbers_to_str=True)
179+
178180
field: str
179181
removed: str
180182
added: str

tests/unit/test_models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ def test_payload_changes_list(webhook_event_change_factory, webhook_event_factor
174174
]
175175

176176

177+
def test_payload_changes_coerces_numbers_to_strings(
178+
webhook_event_change_factory, webhook_event_factory
179+
):
180+
changes = [
181+
webhook_event_change_factory(field="is_confirmed", removed="1", added=0),
182+
]
183+
event = webhook_event_factory(routing_key="bug.modify", changes=changes)
184+
assert event.changed_fields() == ["is_confirmed"]
185+
assert event.changes[0].added == "0"
186+
187+
177188
def test_max_configured_projects_raises_error(action_factory):
178189
actions = [action_factory(whiteboard_tag=str(i)) for i in range(51)]
179190
with pytest.raises(pydantic.ValidationError):

0 commit comments

Comments
 (0)