Skip to content

Commit

Permalink
fix bug with tags endpoints not working
Browse files Browse the repository at this point in the history
  • Loading branch information
danjhd committed Nov 19, 2024
1 parent 662635d commit 0c8a1a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def generate_presigned_url(
@tracer.capture_method(capture_response=False)
def get_clean_item(obj: any) -> dict:
"""Converts a Pydantic model to 'clean' dict (no null or empty properties)"""
obj_dict = json.loads(obj.json())
obj_dict = json.loads(obj.model_dump_json())
remove_null(obj_dict)
return obj_dict

Expand Down
4 changes: 2 additions & 2 deletions functions/api_flows/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from aws_lambda_powertools.utilities.typing import LambdaContext
from boto3.dynamodb.conditions import Key
from mediatimestamp.immutable import TimeRange
from schema import Deletionrequest, Flow, Flowstorage, Flowstoragepost, Source
from schema import Deletionrequest, Flow, Flowstorage, Flowstoragepost, Source, Tags
from utils import (
base_delete_request_dict,
check_delete_source,
Expand Down Expand Up @@ -347,7 +347,7 @@ def put_flow_tag_value(flowId: str, name: str):
if not isinstance(body, str):
raise BadRequestError("Bad request. Invalid flow tag value.") # 400
if flow.root.tags is None:
flow.root.tags = {name: body}
flow.root.tags = Tags(root={name: body})
else:
flow.root.tags.root[name] = body
now = datetime.now().strftime(constants.DATETIME_FORMAT)
Expand Down
4 changes: 2 additions & 2 deletions functions/api_sources/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from aws_lambda_powertools.utilities.parser import parse
from aws_lambda_powertools.utilities.typing import LambdaContext
from boto3.dynamodb.conditions import Key
from schema import Source
from schema import Source, Tags
from utils import (
generate_link_url,
get_clean_item,
Expand Down Expand Up @@ -164,7 +164,7 @@ def put_source_tag_value(sourceId: str, name: str):
raise BadRequestError("Bad request. Invalid Source tag value.") # 400
source: Source = parse(event=item["Item"], model=Source)
if source.tags is None:
source.tags = {name: body}
source.tags = Tags(root={name: body})
else:
source.tags.root[name] = body
now = datetime.now().strftime(constants.DATETIME_FORMAT)
Expand Down

0 comments on commit 0c8a1a8

Please sign in to comment.