Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #633: Problem: cryptic Provider log messages #579

Merged
merged 8 commits into from
Apr 7, 2023
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
3 changes: 3 additions & 0 deletions ocean_provider/file_types/file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def __init__(
userdata=None,
) -> None:
self.url = url
self.query = query
self.userdata = {"query": query}
if userdata:
self.userdata["variables"] = (
Expand All @@ -131,6 +132,8 @@ def __init__(
def validate_dict(self) -> Tuple[bool, Any]:
if not self.url:
return False, "missing graphql endpoint"
if not self.query:
return False, "missing graphql query"
calina-c marked this conversation as resolved.
Show resolved Hide resolved

return True, self

Expand Down
9 changes: 7 additions & 2 deletions ocean_provider/file_types/file_types_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ def validate_and_create(file_obj) -> Tuple[bool, Any]:
userdata=file_obj.get("userdata"),
)
else:
logger.debug(f"Unsupported type {file_obj}")
calina-c marked this conversation as resolved.
Show resolved Hide resolved
return False, f'Unsupported type {file_obj["type"]}'
except TypeError:
logger.debug(f"malformed file object {file_obj}")
return False, "malformed file object."

return instance.validate_dict()
status = instance.validate_dict()
if not status:
logger.debug(f"validate_dict failed on {file_obj}")
logger.debug(f"validate_dict passed on {file_obj}")
return status
1 change: 1 addition & 0 deletions ocean_provider/routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ The following table shows the keys inside a file structure:
| hash | YES | `ipfs` | malformed service files, missing required keys. | |
| transactionId | YES | `arwave` | malformed service files, missing transactionId | |
| url | YES | `graphql` | missing graphql endpoint | |
| query | YES | `graphql` | missing graphql query | |


If no ARWEAVE_GATEWAY is defined in Provider, downloads of arweave files will fail with a 503 status code.
Expand Down
1 change: 1 addition & 0 deletions ocean_provider/routes/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def fileinfo():
files_info = []
for i, file in enumerate(files_list):
file["userdata"] = data.get("userdata")
logger.debug(f"Validating :{file}")
valid, message = FilesTypeFactory.validate_and_create(file)
if not valid:
return error_response(message, 400, logger)
Expand Down