Skip to content

Conversation

@paulineribeyre
Copy link
Collaborator

@paulineribeyre paulineribeyre commented Dec 19, 2025

Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/PD-90 and https://ctds-planx.atlassian.net/browse/PD-92

New Features

Breaking Changes

Bug Fixes

Improvements

  • Fix and re-enable database migrations unit tests

Dependency updates

  • Update Python from 3.9 to 3.13
  • Remove Gino, use sqlalchemy

Deployment changes

@github-actions
Copy link

The style in this PR agrees with black. ✔️

This formatting comment was generated automatically by a script in uc-cdis/wool.

@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

@paulineribeyre paulineribeyre marked this pull request as ready for review December 19, 2025 22:49
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))


def test_all_migrations_have_tests():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copied from gen3-workflow

Comment on lines +186 to +188
def access_token_patcher(client, request, access_token_patcher_param):
"""
Patch the `access_token` function. By default, this fixture is parametrized to return
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed the access token fixtures - the tests were previously running twice even when using access_token_user_only_patcher because of params ["user_token", "client_token"] in autoused access_token_user_client_patcher

@github-actions
Copy link

Failed to Prepare CI environment

Please find the Github Action logs here

@uc-cdis uc-cdis deleted a comment from github-actions bot Dec 22, 2025
@uc-cdis uc-cdis deleted a comment from github-actions bot Dec 22, 2025
@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

Copy link
Contributor

@nss10 nss10 left a comment

Choose a reason for hiding this comment

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

I was able to review the code. It looks good with a few questions/suggestions. I will take another pass at the review to look into the '/tests/' -- Done 🟢

)
).one()
except IntegrityError as e:
if "asyncpg.exceptions.UniqueViolationError" in str(e):
Copy link
Contributor

@nss10 nss10 Dec 22, 2025

Choose a reason for hiding this comment

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

This raised a question for me around the handling of request_id. My understanding is that the request_id is generated server-side as a UUID (here), not provided by the user.
In the unlikely event that a duplicate does occur, should we be returning a 4xx error to the user? From the user’s perspective, the request itself is valid, and the collision is a system-generated artifact rather than an issue with client input.

If that is the case, we might want to try a retry mechanism with a new request_id in such case.

Let me know if I misunderstood this somehow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes a retry would be better. I would rather merge the PR asap and not make further changes but I could add a TODO

In any case, like you said this is very unlikely to happen

def load_modules(app: FastAPI = None) -> None:
# FIXME: Identify the cause for duplicate entry points (PXP-8443)
# Added a set on entry points to dodge the intermittent duplicate modules issue
for ep in set(entry_points()["requestor.modules"]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't gotten back to this issue in years. Did you investigate the issue during the course of this PR?

Copy link
Collaborator Author

@paulineribeyre paulineribeyre Dec 23, 2025

Choose a reason for hiding this comment

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

I couldn't reproduce it anymore so i took my chances and removed it!

Comment on lines +198 to 200
"An error occured while updating role '{}': '{}'".format(
{role["id"]}, str(e)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not change it to an f-string completely?

Copy link
Contributor

@nss10 nss10 left a comment

Choose a reason for hiding this comment

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

Reviewed tests as well. Tests look good overall.

raise


class MigrationRunner:
Copy link
Contributor

Choose a reason for hiding this comment

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

Good abstraction. 👍

with mock.patch("requestor.request_utils.requests") as mock_requests:
# update the request status
res = client.put(f"/request/{request_id}", json={"status": "APPROVED"})
assert res.status_code == 200, res.text
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests Fail early now. Good 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it makes more sense to check the status code before running assert_called_once_with and getting a weird error when the request failed

@paulineribeyre paulineribeyre requested a review from nss10 December 23, 2025 16:27
@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_client_credentials.py 1 1
tests/test_requestor.py 5 5
TOTAL 6 6

Please find the detailed integration test report here

Please find the Github Action logs here

@paulineribeyre paulineribeyre merged commit 8387c82 into master Dec 23, 2025
10 checks passed
@paulineribeyre paulineribeyre deleted the feat/3.13 branch December 23, 2025 19:41
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