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
6 changes: 1 addition & 5 deletions dataconnect/service/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def get_dataset_versions(self, dataset_uuid: UUID) -> list[DatasetVersion]:
A list of :class:`DatasetVersion` objects for the given dataset.

Raises:
ValidationError: If *dataset_uuid* is not a valid, non-zero UUID.
ValidationError: If *dataset_uuid* is not a valid UUID (upstream).
"""
validate_uuid(dataset_uuid, field_name="dataset_uuid", error_code="VAL_C_DATASET_UUID")

request = ResourceQuery(action=_ACTION_LIST_DATASET_VERSIONS).append_body({"dataset_uuid": str(dataset_uuid)})

Expand Down Expand Up @@ -147,9 +146,6 @@ def get_datasets(
Returns:
A :class:`PaginatedResponse` of :class:`Dataset` items matching the criteria.
"""
validate_uuid(study_environment_uuid, field_name="study_environment_uuid", error_code="VAL_C_STUDY_ENV_UUID")
validate_positive_int(page, field_name="page", error_code="VAL_C_PAGE")
validate_positive_int(page_size, field_name="page_size", error_code="VAL_C_PAGE_SIZE")

request = ResourceQuery(action=_ACTION_LIST_DATASETS).append_body(
{
Expand Down
16 changes: 14 additions & 2 deletions dataconnect/transport/arrow_flight/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ def _extract_json_object(text: str) -> str:
"Data Connect > Developer Center."
)

_AUTH_HOST_MSG = (
"Verify that the host URL is correct and that your network "
"allows outbound connections to the specified host and port."
)

_RATE_LIMIT_DETAIL_MSG = "Wait before making more requests."

_ENODIA_PATTERN = re.compile(
r"FlightUnauthenticatedError|Flight returned unauthenticated error",
r"FlightUnauthenticatedError|Flight returned unauthenticated error|Flight returned unavailable error",
Comment thread
ibaig-mdsol marked this conversation as resolved.
re.IGNORECASE,
)

Expand Down Expand Up @@ -107,6 +112,8 @@ def _normalize_enodia_error(error_message: str) -> str:
raw = re.sub(r"\. Client context:.*$", "", raw)
server_msg = raw.strip()

payload_field = "token"

if server_msg:
if re.search("authorization header not present", server_msg, re.IGNORECASE):
error_code = "AUTH_E_001"
Expand All @@ -124,6 +131,11 @@ def _normalize_enodia_error(error_message: str) -> str:
error_code = "AUTH_E_004"
clean_msg = "Rate limit exceeded."
detail_expected = _RATE_LIMIT_DETAIL_MSG
elif re.search("errors resolving", server_msg, re.IGNORECASE):
error_code = "AUTH_E_005"
Comment thread
ibaig-mdsol marked this conversation as resolved.
clean_msg = "Hostname lookup failed."
detail_expected = _AUTH_HOST_MSG
payload_field = "host"
else:
error_code = "AUTH_E_001"
clean_msg = "Authentication token is missing from the request."
Expand All @@ -139,7 +151,7 @@ def _normalize_enodia_error(error_message: str) -> str:
"error_code": error_code,
"message": clean_msg,
"timestamp": timestamp,
"details": [{"field": "token", "message": None, "expected": detail_expected}],
"details": [{"field": payload_field, "message": None, "expected": detail_expected}],
}
Comment thread
ibaig-mdsol marked this conversation as resolved.
json_payload = json.dumps(payload)

Expand Down
Loading