From 23e91d601c8d9a5f47c4faa1c9f308ec24e7da86 Mon Sep 17 00:00:00 2001 From: Matthew Bernhardt Date: Wed, 25 Jun 2025 12:06:21 -0400 Subject: [PATCH] Update lambda response handling The lambda has been updated to return a boolean rather than a string when making a prediction. This means we need to update the cassettes, and also the comparison we perform as part of the response handling. --- app/models/detector/ml_citation.rb | 2 +- test/vcr_cassettes/lambda_citation.yml | 8 +++---- .../lambda_citation_sequence.yml | 24 +++++++++---------- test/vcr_cassettes/lambda_no_citation.yml | 8 +++---- .../lambda_with_wrong_secret.yml | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/models/detector/ml_citation.rb b/app/models/detector/ml_citation.rb index e100583..9a38f69 100644 --- a/app/models/detector/ml_citation.rb +++ b/app/models/detector/ml_citation.rb @@ -140,7 +140,7 @@ def fetch(phrase) response = lambda.post(self.class.lambda_path, payload.to_json) if response.status == 200 - JSON.parse(response.body)['response'] == 'True' + JSON.parse(response.body)['response'] == true else Rails.logger.error(response.body) Sentry.set_extras({ body: response.body }) diff --git a/test/vcr_cassettes/lambda_citation.yml b/test/vcr_cassettes/lambda_citation.yml index 2c83818..fd6fc7d 100644 --- a/test/vcr_cassettes/lambda_citation.yml +++ b/test/vcr_cassettes/lambda_citation.yml @@ -23,15 +23,15 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:22 GMT + - Wed, 25 Jun 2025 16:04:02 GMT Content-Type: - application/json Content-Length: - - '20' + - '18' Connection: - close body: encoding: UTF-8 - string: '{"response": "True"}' - recorded_at: Mon, 16 Jun 2025 15:28:22 GMT + string: '{"response": true}' + recorded_at: Wed, 25 Jun 2025 16:04:02 GMT recorded_with: VCR 6.3.1 diff --git a/test/vcr_cassettes/lambda_citation_sequence.yml b/test/vcr_cassettes/lambda_citation_sequence.yml index 468f5fd..051a479 100644 --- a/test/vcr_cassettes/lambda_citation_sequence.yml +++ b/test/vcr_cassettes/lambda_citation_sequence.yml @@ -23,17 +23,17 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:22 GMT + - Wed, 25 Jun 2025 16:04:01 GMT Content-Type: - application/json Content-Length: - - '20' + - '18' Connection: - close body: encoding: UTF-8 - string: '{"response": "True"}' - recorded_at: Mon, 16 Jun 2025 15:28:22 GMT + string: '{"response": true}' + recorded_at: Wed, 25 Jun 2025 16:04:01 GMT - request: method: post uri: http://localhost:3000/foo @@ -57,17 +57,17 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:25 GMT + - Wed, 25 Jun 2025 16:04:04 GMT Content-Type: - application/json Content-Length: - - '20' + - '18' Connection: - close body: encoding: UTF-8 - string: '{"response": "True"}' - recorded_at: Mon, 16 Jun 2025 15:28:25 GMT + string: '{"response": true}' + recorded_at: Wed, 25 Jun 2025 16:04:04 GMT - request: method: post uri: http://localhost:3000/foo @@ -91,15 +91,15 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:28 GMT + - Wed, 25 Jun 2025 16:04:07 GMT Content-Type: - application/json Content-Length: - - '20' + - '18' Connection: - close body: encoding: UTF-8 - string: '{"response": "True"}' - recorded_at: Mon, 16 Jun 2025 15:28:28 GMT + string: '{"response": true}' + recorded_at: Wed, 25 Jun 2025 16:04:07 GMT recorded_with: VCR 6.3.1 diff --git a/test/vcr_cassettes/lambda_no_citation.yml b/test/vcr_cassettes/lambda_no_citation.yml index dee6ab2..9a0537d 100644 --- a/test/vcr_cassettes/lambda_no_citation.yml +++ b/test/vcr_cassettes/lambda_no_citation.yml @@ -23,15 +23,15 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:22 GMT + - Wed, 25 Jun 2025 16:04:02 GMT Content-Type: - application/json Content-Length: - - '21' + - '19' Connection: - close body: encoding: UTF-8 - string: '{"response": "False"}' - recorded_at: Mon, 16 Jun 2025 15:28:22 GMT + string: '{"response": false}' + recorded_at: Wed, 25 Jun 2025 16:04:02 GMT recorded_with: VCR 6.3.1 diff --git a/test/vcr_cassettes/lambda_with_wrong_secret.yml b/test/vcr_cassettes/lambda_with_wrong_secret.yml index 0490f96..af014eb 100644 --- a/test/vcr_cassettes/lambda_with_wrong_secret.yml +++ b/test/vcr_cassettes/lambda_with_wrong_secret.yml @@ -23,7 +23,7 @@ http_interactions: Server: - Werkzeug/3.0.6 Python/3.11.10 Date: - - Mon, 16 Jun 2025 15:28:22 GMT + - Wed, 25 Jun 2025 16:04:00 GMT Content-Type: - application/json Content-Length: @@ -34,5 +34,5 @@ http_interactions: encoding: UTF-8 string: '{"error": "Challenge secret missing or mismatch", "error_details": null}' - recorded_at: Mon, 16 Jun 2025 15:28:22 GMT + recorded_at: Wed, 25 Jun 2025 16:04:00 GMT recorded_with: VCR 6.3.1