From db2d04d05d7960b75a07a8036748bcb281668b6f Mon Sep 17 00:00:00 2001 From: David Whittaker <84562015+whitdog47@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:57:48 -0700 Subject: [PATCH 1/5] Correcting rounding strategy (#5373) --- tests/incident_cost/test_incident_cost_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/incident_cost/test_incident_cost_service.py b/tests/incident_cost/test_incident_cost_service.py index 0e22ced9d4e0..c38f8ee04619 100644 --- a/tests/incident_cost/test_incident_cost_service.py +++ b/tests/incident_cost/test_incident_cost_service.py @@ -109,7 +109,7 @@ def test_calculate_incident_response_cost_with_cost_model( ): """Tests that the incident cost is calculated correctly when a cost model is enabled.""" from datetime import timedelta - from decimal import Decimal, ROUND_UP + from decimal import Decimal, ROUND_HALF_UP from dispatch.incident_cost.service import update_incident_response_cost, get_hourly_rate from dispatch.incident_cost_type import service as incident_cost_type_service from dispatch.participant_activity.service import ( @@ -154,8 +154,8 @@ def test_calculate_incident_response_cost_with_cost_model( ) * hourly_rate + orig_total_incident_cost assert cost - assert cost == Decimal(expected_incident_cost).quantize(cost, rounding=ROUND_UP) - assert cost == Decimal(incident.total_cost).quantize(cost, rounding=ROUND_UP) + assert cost == Decimal(expected_incident_cost).quantize(cost, rounding=ROUND_HALF_UP) + assert cost == Decimal(incident.total_cost).quantize(cost, rounding=ROUND_HALF_UP) def test_calculate_incident_response_cost_with_cost_model__no_enabled_plugins( From 968ad5c7139e927a3babf1a08ec54657d4d6d1e4 Mon Sep 17 00:00:00 2001 From: Jason Litton Date: Tue, 22 Oct 2024 15:49:44 -0600 Subject: [PATCH 2/5] bug(core-ticket): Add dispatch_weblink field to core ticket plugin (#5377) * fix(core-ticket): Add dispatch_weblink field to core ticket plugin When using the core ticket plugin, we're getting the error `TypeError: DispatchTicketPlugin.update() got an unexpected keyword argument 'dispatch_weblink'` This field was added for the Jira ticket plugin but never added to the core plugin. Since the plugin returns no matter the arguments, I've simply added the field. * add newline that ide removed --- src/dispatch/plugins/dispatch_core/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dispatch/plugins/dispatch_core/plugin.py b/src/dispatch/plugins/dispatch_core/plugin.py index 2dbeb354a615..f8e881f160aa 100644 --- a/src/dispatch/plugins/dispatch_core/plugin.py +++ b/src/dispatch/plugins/dispatch_core/plugin.py @@ -211,6 +211,7 @@ def update( document_weblink: str, storage_weblink: str, conference_weblink: str, + dispatch_weblink: str, cost: float, incident_type_plugin_metadata: dict = None, ): From 63ae82068078544cc100b5a32d3d5915e7d71c37 Mon Sep 17 00:00:00 2001 From: Jason Litton Date: Tue, 22 Oct 2024 15:58:23 -0600 Subject: [PATCH 3/5] Revert python version bump (#5379) The move to python 3.14 breaks the docker build. The srsly package doesn't have a compatible wheel with anything above 3.12 right now, and it's using deprecated methods, so it can't be built by 3.14 yet. Because of this, `docker build .` is broken on master. Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 23ae6081f361..a0f0e10ce95f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.13.0-slim-bullseye as sdist +FROM python:3.11.4-slim-bullseye as sdist LABEL maintainer="oss@netflix.com" LABEL org.opencontainers.image.title="Dispatch PyPI Wheel" @@ -56,7 +56,7 @@ RUN YARN_CACHE_FOLDER="$(mktemp -d)" \ && mv /usr/src/dispatch/dist /dist # This is the image to be run -FROM python:3.13.0-slim-bullseye +FROM python:3.11.4-slim-bullseye LABEL maintainer="oss@dispatch.io" LABEL org.opencontainers.image.title="Dispatch" From 295a60feba435c56bc3158d47e6a7efe4bde563e Mon Sep 17 00:00:00 2001 From: Alicia Matsumoto <56315176+aliciamatsumoto@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:03:34 -0400 Subject: [PATCH 4/5] fix get_signal_filter args (#5376) Co-authored-by: Alicia Matsumoto Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --- src/dispatch/signal/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/signal/views.py b/src/dispatch/signal/views.py index 6b38f20c5568..e8dab18aabe7 100644 --- a/src/dispatch/signal/views.py +++ b/src/dispatch/signal/views.py @@ -241,7 +241,7 @@ def update_filter( signal_filter_in: SignalFilterUpdate, ): """Updates an existing signal filter.""" - signal_filter = get_signal_filter(db_session=db_session, signal_id=signal_filter_id) + signal_filter = get_signal_filter(db_session=db_session, signal_filter_id=signal_filter_id) if not signal_filter: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, From 9f7ecd740466c8653d4d82831f951ad3a94745bd Mon Sep 17 00:00:00 2001 From: Jason Litton Date: Tue, 22 Oct 2024 16:14:19 -0600 Subject: [PATCH 5/5] bug(slack/api): Make slack /event respond to challenge (#5375) * fix(slack): Make slack /events respond to challenge When configuring event listening for a slack app, your endpoint is required to respond correctly to the slack challenge that is sent. If your endpoint does not respond correctly, slack will not let you use it. Currently, the events endpoint does not respond correctly to the challenge because it is using a background thread to process all incoming events and responding with a static response. In order to use the events endpoint correctly (including using an @ in the incident channel to add an observer), that endpoint has to respond. I altered the event post to check the body for a "url_verification" type and, if it exists, process the event synchronously in the same way the `actions` endpoint does. Otherwise, process async like it always has. * add reformatting --------- Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --- src/dispatch/plugins/dispatch_slack/endpoints.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dispatch/plugins/dispatch_slack/endpoints.py b/src/dispatch/plugins/dispatch_slack/endpoints.py index 05785a844c57..9ccdf425c215 100644 --- a/src/dispatch/plugins/dispatch_slack/endpoints.py +++ b/src/dispatch/plugins/dispatch_slack/endpoints.py @@ -81,7 +81,18 @@ def get_request_handler(request: Request, body: bytes, organization: str) -> Sla ) async def slack_events(request: Request, organization: str, body: bytes = Depends(get_body)): """Handle all incoming Slack events.""" + handler = get_request_handler(request=request, body=body, organization=organization) + try: + body_json = json.loads(body) + # if we're getting the url verification request, + # handle it synchronously so that slack api verification works + if body_json.get("type") == "url_verification": + return handler.handle(req=request, body=body) + except json.JSONDecodeError: + pass + + # otherwise, handle it asynchronously task = BackgroundTask(handler.handle, req=request, body=body) return JSONResponse( background=task,