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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pydantic
from sentry.hybridcloud.rpc import RpcModel


class RpcOrganizationSlugReservation(pydantic.BaseModel):
class RpcOrganizationSlugReservation(RpcModel):
id: int
organization_id: int
user_id: int | None
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/services/organization/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class OrganizationOptions(pydantic.BaseModel):


class PostProvisionOptions(pydantic.BaseModel):
sentry_options: Any | None # Placeholder for any sentry post-provisioning data
getsentry_options: Any | None # Reserved for getsentry post-provisioning data
sentry_options: Any | None = None # Placeholder for any sentry post-provisioning data
getsentry_options: Any | None = None # Reserved for getsentry post-provisioning data


class OrganizationProvisioningOptions(pydantic.BaseModel):
Expand Down
7 changes: 5 additions & 2 deletions src/sentry/users/services/lost_password_hash/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# in modules such as this one where hybrid cloud data models or service classes are
# defined, because we want to reflect on type annotations and avoid forward references.

import datetime
from datetime import datetime

from django.utils import timezone
from pydantic import Field

from sentry.hybridcloud.rpc import RpcModel
from sentry.models.lostpasswordhash import LostPasswordHash
Expand All @@ -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.


def get_absolute_url(self, mode: str = "recover") -> str:
return LostPasswordHash.get_lostpassword_url(self.user_id, self.hash, mode)
2 changes: 1 addition & 1 deletion tests/sentry/api/endpoints/test_event_ai_suggested_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def dummy_response(*args, **kwargs):
finish_reason="stop",
)
],
created=time.time(),
created=int(time.time()),
model="gpt3.5-trubo",
object="chat.completion",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/feedback/usecases/test_create_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_dummy_response(*args, **kwargs):
finish_reason="stop",
)
],
created=time.time(),
created=int(time.time()),
model="gpt3.5-trubo",
object="chat.completion",
)
Expand Down
Loading