Skip to content

Commit

Permalink
fix: coerce pydantic AnyUri to str when needed (#377)
Browse files Browse the repository at this point in the history
fixes #376
  • Loading branch information
dwinston authored Nov 13, 2023
1 parent fd3aee9 commit 1eacc43
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions nmdc_runtime/site/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from fastjsonschema import JsonSchemaValueException
from frozendict import frozendict
from linkml_runtime.dumpers import json_dumper
from pydantic import BaseModel
from pydantic import BaseModel, AnyUrl
from pymongo import MongoClient, ReplaceOne, InsertOne
from terminusdb_client import WOQLClient
from toolz import get_in
Expand Down Expand Up @@ -194,15 +194,17 @@ def get_object_bytes(self, object_id) -> requests.Response:
access = AccessURL(
**self.get_object_access(object_id, method.access_id).json()
)
if access.url.startswith(
if str(access.url).startswith(
os.getenv("API_HOST_EXTERNAL")
) and self.base_url == os.getenv("API_HOST"):
access.url = access.url.replace(
os.getenv("API_HOST_EXTERNAL"), os.getenv("API_HOST")
access.url = AnyUrl(
str(access.url).replace(
os.getenv("API_HOST_EXTERNAL"), os.getenv("API_HOST")
)
)
else:
access = AccessURL(url=method.access_url.url)
return requests.get(access.url)
return requests.get(str(access.url))

def list_jobs(self, list_request=None):
if list_request is None:
Expand Down

0 comments on commit 1eacc43

Please sign in to comment.