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

Allow Namespace pydantic model to have a null metadata_ entry #1063

Merged
merged 4 commits into from
Jan 29, 2025

Conversation

soapy1
Copy link
Contributor

@soapy1 soapy1 commented Jan 29, 2025

Fixes #1062

Description

This PR updates the pydantic model for Namespace so that the metadata_ field can be null. This field is nullable, and the default value is an empty dict:

class Namespace(Base):
    """Namespace for resources"""

    . . .

    metadata_: Mapped[Optional[dict]] = mapped_column(JSON, default=dict, nullable=True)

    . . .

In order for pydantic models to allow values to be None, they must set them as Optional. If not, an error will be thrown.

In older deployments on conda-store it is possible for this field to actually be NULL (see the explanation #1062 (comment)), resulting in an error.

Additional notes

While sorting this out I also checked for other orm fields that were explicitly set to nullable=True and ensured that their pydantic counterparts are set to Optional.

Pull request checklist

  • Did you test this change locally?
  • Did you update the documentation (if required)?
  • Did you add/update relevant tests for this change (if required)?

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for conda-store canceled.

Name Link
🔨 Latest commit e9ad110
🔍 Latest deploy log https://app.netlify.com/sites/conda-store/deploys/679a723fcaec1d00088eb250

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for conda-store canceled.

Name Link
🔨 Latest commit e80d0d8
🔍 Latest deploy log https://app.netlify.com/sites/conda-store/deploys/679a864a0c29f50008ea29aa

Copy link
Contributor

@peytondmurray peytondmurray left a comment

Choose a reason for hiding this comment

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

I added a comment that provides context here, but otherwise looks good. 🚢

@soapy1 soapy1 merged commit a965967 into conda-incubator:main Jan 29, 2025
14 checks passed
@soapy1 soapy1 deleted the null_namespace_metadata_ branch January 29, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done 💪🏾
Development

Successfully merging this pull request may close these issues.

[BUG] - GET /api/v1/namespace/ returns a 500
2 participants