Skip to content

Conversation

@HarikaBishai
Copy link
Collaborator

@HarikaBishai HarikaBishai commented Dec 8, 2025

Commands to update the packages


uv pip compile requirements-dev.in --upgrade -o requirements-dev.txt
uv pip compile requirements.in --upgrade -o requirements.txt

Key Changes

Dependency Updates

  • Beanie upgraded 1.30.0 → 2.0.1
  • FastAPI upgraded 0.116.1 → 0.124.0
  • Pydantic upgraded 2.11.7 → 2.12.5
  • Other related packages updated as part of the refresh.

Beanie 2.x Migration Summary

  • Replaced the deprecated get_motor_collection() with the new get_pymongo_collection() API.
  • Removed usage of fetch_links=True, as Beanie 2.x no longer supports automatic link loading.
  • Previously, fetch_links=True would automatically load the linked user object for an API key.
    Since this is no longer available, we now manually fetch the user object using the reference ID.

@HarikaBishai HarikaBishai self-assigned this Dec 8, 2025
@HarikaBishai HarikaBishai marked this pull request as draft December 8, 2025 21:53
@HarikaBishai HarikaBishai requested a review from Copilot December 9, 2025 16:00
@HarikaBishai HarikaBishai marked this pull request as ready for review December 9, 2025 16:00
Copy link
Contributor

Copilot AI left a comment

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 package dependencies to their latest versions using uv pip compile, with a major update to Beanie (from 1.30.0 to 2.0.1) requiring API adaptations.

Key changes:

  • Updated Beanie from 1.30.0 to 2.0.1, requiring migration from Motor-specific API to PyMongo API
  • Removed deprecated fetch_links parameter and implemented manual link fetching for API key lookups
  • Updated multiple core dependencies including FastAPI (0.116.1 → 0.124.0), Pydantic (2.11.7 → 2.12.5), and numerous other packages

Reviewed changes

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

File Description
src/nsls2api/tests/conftest.py Updated test cleanup to use get_pymongo_collection() instead of deprecated get_motor_collection() for Beanie 2.0 compatibility
src/nsls2api/infrastructure/security.py Removed fetch_links parameter from find_one() call and added manual link fetching logic to resolve user relationships
requirements.txt Comprehensive package updates including major version bumps for Beanie, FastAPI, Pydantic, and 40+ other dependencies
requirements-dev.txt Development dependency updates including testing, linting, and development tools across 60+ packages

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

HarikaBishai and others added 2 commits December 9, 2025 11:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@padraic-shafer padraic-shafer left a comment

Choose a reason for hiding this comment

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

I haven't understood why changes to get_..._collection() and fetch_links are needed.
Could you please include the rationale in the PR description?

@HarikaBishai
Copy link
Collaborator Author

HarikaBishai commented Dec 11, 2025

I haven't understood why changes to get_..._collection() and fetch_links are needed. Could you please include the rationale in the PR description?

I have removed fetch_links and updated get_motor_collection to get_pymongo_collection() as they got deprecated in new Beanie version 2.0.1 , please check the [comment above ] (#215 (review)), I will add the same in description.

@danielballan
Copy link
Collaborator

Looks fine, but it would be good to know what fetch_links was doing before and why it's no longer needed. Understood that the option was removed, but it would be good to understand what replaces it or why we don't need whatever it was doing.

@HarikaBishai
Copy link
Collaborator Author

Looks fine, but it would be good to know what fetch_links was doing before and why it's no longer needed. Understood that the option was removed, but it would be good to understand what replaces it or why we don't need whatever it was doing.

fetch_links=True automatically loaded related data when querying the database (like getting the user info when fetching an API key). Beanie 2.x has a bug that breaks this feature. Instead, we now manually fetch the related data in a separate query right after , same end result, just done in two steps instead of one.

Copy link
Collaborator

@padraic-shafer padraic-shafer left a comment

Choose a reason for hiding this comment

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

Updates to the collection methods are consistent with beanie 2.0 documentation.

Changes to the API key method appears to be working around a symptom of a larger issue. Namely, that motor is no longer supported in beanie 2.0, and should be replaced by pymongo.

See, e.g., #216.

I'll put this PR into draft for now, and we'll revisit it later in the Shutdown.

@padraic-shafer padraic-shafer marked this pull request as draft December 13, 2025 14:55
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