Skip to content

[MCC-1501157] Python Lib - Use Error Handler, Document and Update Messages Across Studies, Connect, DataSets and Dataset_versions#34

Merged
butsyk-mdsol merged 2 commits into
mainfrom
feat/MCC-1501157_error_handling
May 21, 2026
Merged

[MCC-1501157] Python Lib - Use Error Handler, Document and Update Messages Across Studies, Connect, DataSets and Dataset_versions#34
butsyk-mdsol merged 2 commits into
mainfrom
feat/MCC-1501157_error_handling

Conversation

@ibaig-mdsol

@ibaig-mdsol ibaig-mdsol commented May 20, 2026

Copy link
Copy Markdown
Contributor

feature

Checklist

  • Review the pull request to fix typos and ensure variable/function names are intuitive, etc.
  • Make sure the pull request does not have excessive number of unnecessary commits. Utilize the git commit --amend --no-edit command to reduce commit messages when making small file changes (like changing linespacing).
  • Make sure you have added unit tests for the code changes. Tests should be added in the tests/ folder.
  • Modify docs, if required. Add any new documentation in the doc/ folder.
  • Rebase on latest active development branch (develop/main).

Changes Summary

Added/Updated Error Handlers for:

  • connect()
  • get_studies()
  • get_datasets()
  • get_dataset_versions()

Jupyter file:

MCC-1501157.ipynb

Screenshot

image

Errors Table

<style type="text/css"></style>

Function Call Error Code How to test Message field Detail
Connect AUTH_E_001 No Token Authentication token is missing from the request. token Ensure you provide the correct user authentication token. The user token must be valid and generated from the SDK Key Management page in iMedidata > Data Connect > Developer Center.
  AUTH_E_002 Code Change Authentication token is invalid or malformed. token Ensure you provide the correct user authentication token. The user token must be valid and generated from the SDK Key Management page in iMedidata > Data Connect > Developer Center.
  AUTH_E_003 Bad Token Authentication token is expired or revoked. token Ensure you provide the correct user authentication token. The user token must be valid and generated from the SDK Key Management page in iMedidata > Data Connect > Developer Center.
  AUTH_E_004   Rate limit exceeded.    
  AUTH_E_005 Bad/No Host Hostname lookup failed host Verify that the host URL is correct and that your network allows outbound connections to the specified host and port.
Studies INT_002 Arrow Failed to fetch studies.   Retry the request and if the issue persists, reach out to Medidata Support Team for assistance.
Datasets AUTHZ_001 SE outside Data Connect Authorization error. You don't have permissions to perform this action. user_uuid or study_env_uuid User 32fe67f3-701a-4db7-99f8-05024b944c5c is not authorized to access the study environment: 48cff414-7dc3-4115-9509-7ea9d8b3e060.
  VAL_005 study_environment_uuid= None Missing or invalid study environment uuid. study_env_uuid Review and provide the correct study_environment_uuid.
  VAL_003 page_size=110, Invalid page size. page_size Invalid page size: 110.
  VAL_011 page=100,page_size=100, dataset_uuid must not be empty. page Requested page 100 exceeds available pages 29.
Dataset Versions VAL_006 dataset_uuid="abc" Invalid dataset uuid. dataset_uuid The dataset_uuid is not a valid UUID.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Python DataConnect library’s error handling/normalization to provide more actionable, structured error messages (particularly around authentication/connectivity scenarios), and adjusts service-layer behavior for dataset-related endpoints.

Changes:

  • Extended Arrow Flight Enodia error normalization to recognize additional failure cases and provide targeted guidance (e.g., hostname lookup failures).
  • Adjusted error payload details to vary the reported “field” depending on the detected failure type.
  • Removed client-side validation in get_datasets() / get_dataset_versions() in favor of upstream validation (though get_datasets() now conflicts with existing expectations in the codebase).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
dataconnect/transport/arrow_flight/error_handler.py Expands/adjusts normalization of certain Arrow Flight error messages into structured SDK errors.
dataconnect/service/default.py Removes some local input validation and updates docstrings around validation responsibility.
Comments suppressed due to low confidence (1)

dataconnect/service/default.py:154

  • Input validation for study_environment_uuid, page, and page_size was removed, but this method still assumes numeric page_size later (e.g., total_pages = (total_records + page_size - 1) // page_size). With non-int or <=0 values this can now raise TypeError or produce invalid requests, and it also breaks the existing contract tested in tests/test_get_datasets_paginated.py (which expects ValidationError on invalid inputs). Reintroduce the validations (or provide equivalent type/range checks with consistent ValidationErrors) before building the request body.
        request = ResourceQuery(action=_ACTION_LIST_DATASETS).append_body(
            {
                "study_environment_uuid": str(study_environment_uuid),
                "search_dataset_name": search_dataset_name,
                "page": page,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dataconnect/transport/arrow_flight/error_handler.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

dataconnect/service/default.py:156

  • Input validation for study_environment_uuid/page/page_size was removed, but the SDK has unit tests expecting ValidationError for invalid UUIDs and non-positive/non-int pagination values (see tests/test_get_datasets_paginated.py). Without these checks, invalid inputs will be sent to the transport and pagination metadata can contain invalid values. Either restore the local validations or update the contract/tests and ensure upstream errors are translated consistently.

        request = ResourceQuery(action=_ACTION_LIST_DATASETS).append_body(
            {
                "study_environment_uuid": str(study_environment_uuid),
                "search_dataset_name": search_dataset_name,
                "page": page,
                "page_size": page_size,
            }

Comment thread dataconnect/transport/arrow_flight/error_handler.py
Comment thread dataconnect/transport/arrow_flight/error_handler.py
@butsyk-mdsol
butsyk-mdsol merged commit c6bbb44 into main May 21, 2026
7 checks passed
@butsyk-mdsol
butsyk-mdsol deleted the feat/MCC-1501157_error_handling branch May 21, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants