From 811214941bc7a05d5c536d0a81ca36d29528630b Mon Sep 17 00:00:00 2001 From: Nik Gupta Date: Tue, 3 Dec 2024 13:23:55 +0000 Subject: [PATCH 1/2] [Confirm] Log GraphQL errors. --- perllib/Integrations/Confirm.pm | 7 +++++- t/integrations/confirm.t | 43 +++++++++++++++++++++++++++++++++ t/integrations/confirm.yml | 2 ++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 t/integrations/confirm.t create mode 100644 t/integrations/confirm.yml diff --git a/perllib/Integrations/Confirm.pm b/perllib/Integrations/Confirm.pm index 1d91cfc45..c824c3d26 100644 --- a/perllib/Integrations/Confirm.pm +++ b/perllib/Integrations/Confirm.pm @@ -315,13 +315,18 @@ sub perform_request_graphql { my $body = { query => $query, }; + my $encoded_body = encode_json($body); - $request->content(encode_json($body)); + $request->content($encoded_body); my $response = $self->ua->request($request); my $content = decode_json($response->content); + if ($content->{errors} && @{$content->{errors}}) { + $self->logger->warn("Got errors in response to GraphQL query $encoded_body: " . $response->content); + } + return $content; } diff --git a/t/integrations/confirm.t b/t/integrations/confirm.t new file mode 100644 index 000000000..1888cbff1 --- /dev/null +++ b/t/integrations/confirm.t @@ -0,0 +1,43 @@ +package Integrations::Confirm::Dummy; +use Path::Tiny; +use Moo; +extends 'Integrations::Confirm'; +sub _build_config_file { path(__FILE__)->sibling("confirm.yml")->stringify } + +package main; + +use strict; +use warnings; + +use Test::More; +use Test::MockModule; +use Test::Output; +use HTTP::Response; +use JSON::MaybeXS; + +BEGIN { $ENV{TEST_MODE} = 1; } + +my $lwp = Test::MockModule->new('LWP::UserAgent'); + +$lwp->mock(request => sub { + return HTTP::Response->new(200, 'OK', [], encode_json({ + data => {}, + errors => [ + { + message => "Uh-oh spaghettio!", + } + ] + }) + ); +}); + +my $integration = Integrations::Confirm::Dummy->new; + +subtest "GraphQL errors are logged " => sub { + local $ENV{TEST_LOGGER} = 'warn'; + stderr_like { + $integration->perform_request_graphql(type => 'job_types'); + } qr/.*Uh-oh spaghettio!.*/, 'Got expected warning log for errors.'; +}; + +done_testing; diff --git a/t/integrations/confirm.yml b/t/integrations/confirm.yml new file mode 100644 index 000000000..7bf19bd91 --- /dev/null +++ b/t/integrations/confirm.yml @@ -0,0 +1,2 @@ +graphql_url: "http://example.org/graphql" +graphql_key: "key" From e3fa8890dc0ca6ec14fa31c3d610a18d53c46a2d Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 6 Dec 2024 13:12:35 +0000 Subject: [PATCH 2/2] [Brent] Include car park issue type in notes. --- perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm b/perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm index f91390461..8f901c7e7 100644 --- a/perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm +++ b/perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm @@ -13,6 +13,10 @@ around process_service_request_args => sub { my ($orig, $class, $args) = @_; my $request = $class->$orig($args); + if ($args->{attributes}{CarParkIssueType}) { + $args->{attributes}{description} .= " | " . $args->{attributes}{CarParkIssueType}; + } + # Missed collection if ($request->{event_type} == 2891) { my $service_id = $args->{attributes}{service_id};