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

fix(hybrid-cloud): Adds defaults to provisioning model fields, lost_password_hash model #74766

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

GabeVillalobos
Copy link
Member

Fixes a few issues that crop up as errors in the Pydantic upgrade work:

  • Optional fields without defaults now cause failures instead of assuming a value of None
  • Type mismatches between fields are no longer automatically coerced without an additional config setting

…assword_hash model

Also fixes test type mismatches.
@GabeVillalobos GabeVillalobos requested review from a team as code owners July 23, 2024 19:07
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 23, 2024
@@ -13,7 +16,7 @@ class RpcLostPasswordHash(RpcModel):
id: int = -1
user_id: int = -1
hash: str = ""
date_added = datetime.datetime
date_added: datetime = Field(default_factory=timezone.now)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not super sure we want this to be the default. I could also remove this entirely and just assume the caller needs to provide one, but I this was failing tests for whatever reason 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a reasonable default. Forcing the caller to provide one is reasonable in tests, but not in production, due to the reality that there will be (increasing) version drift between callers and receivers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever default does it exist, it should be safe for the purpose of backwards compatibility, which depends on the use case.

Copy link
Member

Choose a reason for hiding this comment

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

This default seems fine to me. Looking at the existing usage, we only create RpcLostPasswordHash by serializing an ORM object, which would have date_added set as well.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.15%. Comparing base (ffb67db) to head (7b86b14).
Report is 41 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #74766       +/-   ##
===========================================
+ Coverage   57.09%   78.15%   +21.06%     
===========================================
  Files        6721     6731       +10     
  Lines      299870   300259      +389     
  Branches    51594    51647       +53     
===========================================
+ Hits       171210   234669    +63459     
+ Misses     123886    59267    -64619     
- Partials     4774     6323     +1549     
Files Coverage Δ
...ervices/control_organization_provisioning/model.py 100.00% <100.00%> (ø)
src/sentry/services/organization/model.py 100.00% <100.00%> (ø)
.../sentry/users/services/lost_password_hash/model.py 100.00% <100.00%> (+10.00%) ⬆️

... and 2009 files with indirect coverage changes

@@ -13,7 +16,7 @@ class RpcLostPasswordHash(RpcModel):
id: int = -1
user_id: int = -1
hash: str = ""
date_added = datetime.datetime
date_added: datetime = Field(default_factory=timezone.now)
Copy link
Member

Choose a reason for hiding this comment

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

This default seems fine to me. Looking at the existing usage, we only create RpcLostPasswordHash by serializing an ORM object, which would have date_added set as well.

@GabeVillalobos GabeVillalobos merged commit be18d81 into master Jul 24, 2024
51 checks passed
@GabeVillalobos GabeVillalobos deleted the gv/rpc-model-fixes-for-pydantic-upgrade branch July 24, 2024 16:34
@GabeVillalobos GabeVillalobos added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Jul 24, 2024
@getsentry-bot
Copy link
Contributor

PR reverted: bb82492

getsentry-bot added a commit that referenced this pull request Jul 24, 2024
…, lost_password_hash model (#74766)"

This reverts commit be18d81.

Co-authored-by: GabeVillalobos <5643012+GabeVillalobos@users.noreply.github.com>
GabeVillalobos added a commit that referenced this pull request Jul 24, 2024
…fields, lost_password_hash model (#74766)

This reverts commit bb82492.
GabeVillalobos added a commit that referenced this pull request Jul 24, 2024
Christinarlong pushed a commit that referenced this pull request Jul 26, 2024
Christinarlong pushed a commit that referenced this pull request Jul 26, 2024
…, lost_password_hash model (#74766)"

This reverts commit be18d81.

Co-authored-by: GabeVillalobos <5643012+GabeVillalobos@users.noreply.github.com>
Christinarlong pushed a commit that referenced this pull request Jul 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants