Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lambdas/backend/src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

GENERIC_SERVER_ERROR_DIAGNOSTICS_MESSAGE = "Unable to process request. Issue may be transient."
# Maximum response size for an AWS Lambda function
MAX_RESPONSE_SIZE_BYTES = 6 * 1024 * 1024
MAX_SEARCH_RESPONSE_SIZE_BYTES = 1 * 1024 * 1024
4 changes: 2 additions & 2 deletions lambdas/backend/src/controller/fhir_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fhir.resources.R4B.identifier import Identifier

from common.get_service_url import get_service_url
from constants import MAX_RESPONSE_SIZE_BYTES
from constants import MAX_SEARCH_RESPONSE_SIZE_BYTES
from controller.aws_apig_event_utils import (
get_multi_value_query_params,
get_path_parameter,
Expand Down Expand Up @@ -213,7 +213,7 @@ def _search_immunizations_by_target_disease(self, search_params: dict[str, list[
def _create_search_response(self, search_bundle: Bundle) -> dict:
search_response_json = search_bundle.json(use_decimal=True)

if len(search_response_json) > MAX_RESPONSE_SIZE_BYTES:
if len(search_response_json) > MAX_SEARCH_RESPONSE_SIZE_BYTES:
raise TooManyResultsError("Search returned too many results. Please narrow down the search")

prepared_search_bundle = self._prepare_search_bundle(search_response_json)
Expand Down
2 changes: 1 addition & 1 deletion lambdas/backend/tests/controller/test_fhir_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ def test_search_immunizations_returns_a_validation_error_when_optional_params_in
)
self.service.search_immunizations.assert_not_called()

@patch("controller.fhir_controller.MAX_RESPONSE_SIZE_BYTES", 5)
@patch("controller.fhir_controller.MAX_SEARCH_RESPONSE_SIZE_BYTES", 5)
def test_search_immunizations_raises_error_if_too_many_results_found(self):
"""it should return an error if there are too many results in the response for Lambda to handle. In reality,
highly unlikely. If a concern, pagination should be implemented."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def test_search_by_target_disease_with_mixed_valid_and_invalid_returns_200_with_
self.assertIn("invalid-no-pipe", call_args[1]["invalid_target_diseases"][0])
self.assertIn("Invalid format", call_args[1]["invalid_target_diseases"][0])

@patch("controller.fhir_controller.MAX_RESPONSE_SIZE_BYTES", 5)
@patch("controller.fhir_controller.MAX_SEARCH_RESPONSE_SIZE_BYTES", 5)
def test_search_by_target_disease_returns_400_when_response_too_large(self):
"""it should return the same narrow-the-search error for oversized target-disease searches"""
self.mock_redis.hget.side_effect = self._hget_target_disease_codes_and_mmr
Expand Down
Loading