diff --git a/api/conftest.py b/api/conftest.py index ab0581197bb81..94c6668ce9e45 100644 --- a/api/conftest.py +++ b/api/conftest.py @@ -580,7 +580,7 @@ def flagsmith_environments_v2_table(dynamodb) -> Table: }, ], AttributeDefinitions=[ - {"AttributeName": "environment_id", "AttributeType": "N"}, + {"AttributeName": "environment_id", "AttributeType": "S"}, {"AttributeName": "document_key", "AttributeType": "S"}, ], BillingMode="PAY_PER_REQUEST", diff --git a/api/environments/dynamodb/dynamodb_wrapper.py b/api/environments/dynamodb/dynamodb_wrapper.py index b7e34b48f760b..0158c775128d9 100644 --- a/api/environments/dynamodb/dynamodb_wrapper.py +++ b/api/environments/dynamodb/dynamodb_wrapper.py @@ -190,7 +190,7 @@ def get_identity_overrides_by_feature_id( try: response = self._table.query( KeyConditionExpression=Key(ENVIRONMENTS_V2_PARTITION_KEY).eq( - environment_id, + str(environment_id), ) & Key(ENVIRONMENTS_V2_SORT_KEY).begins_with( get_environments_v2_identity_override_document_key( diff --git a/api/environments/dynamodb/types.py b/api/environments/dynamodb/types.py index de11ddc77ae59..d43d124e88e14 100644 --- a/api/environments/dynamodb/types.py +++ b/api/environments/dynamodb/types.py @@ -74,7 +74,7 @@ def _save(self): class IdentityOverrideV2(BaseModel): - environment_id: int + environment_id: str document_key: str environment_api_key: str feature_state: FeatureStateModel diff --git a/api/tests/unit/environments/dynamodb/test_unit_dynamodb_environment_v2_wrapper.py b/api/tests/unit/environments/dynamodb/test_unit_dynamodb_environment_v2_wrapper.py index 6d882dd12253d..01825897ebfaa 100644 --- a/api/tests/unit/environments/dynamodb/test_unit_dynamodb_environment_v2_wrapper.py +++ b/api/tests/unit/environments/dynamodb/test_unit_dynamodb_environment_v2_wrapper.py @@ -30,7 +30,7 @@ def test_environment_v2_wrapper__get_identity_overrides__return_expected( identity_uuid = str(uuid.uuid4()) identifier = "identity1" override_document = { - "environment_id": environment.id, + "environment_id": str(environment.id), "document_key": f"identity_override:{feature.id}:{identity_uuid}", "environment_api_key": environment.api_key, "identifier": identifier, @@ -67,7 +67,7 @@ def test_environment_v2_wrapper__update_identity_overrides__put_expected( identity_uuid = str(uuid.uuid4()) override_document = IdentityOverrideV2.parse_obj( { - "environment_id": environment.id, + "environment_id": str(environment.id), "document_key": f"identity_override:{feature.id}:{identity_uuid}", "environment_api_key": environment.api_key, "feature_state": map_feature_state_to_engine(feature_state), @@ -105,7 +105,7 @@ def test_environment_v2_wrapper__update_identity_overrides__delete_expected( override_document_data = map_identity_override_to_identity_override_document( IdentityOverrideV2.parse_obj( { - "environment_id": environment.id, + "environment_id": str(environment.id), "document_key": f"identity_override:{feature.id}:{identity_uuid}", "environment_api_key": environment.api_key, "feature_state": map_feature_state_to_engine(feature_state), diff --git a/api/util/mappers/dynamodb.py b/api/util/mappers/dynamodb.py index 5bbb5b09edbeb..2b39e0525e20d 100644 --- a/api/util/mappers/dynamodb.py +++ b/api/util/mappers/dynamodb.py @@ -55,7 +55,7 @@ def map_environment_to_environment_v2_document( return { **map_environment_to_environment_document(environment), "document_key": "META", - "environment_id": _decimal_encoder(environment.id), + "environment_id": str(environment.id), }