-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(integrations): Handle missing default org owner in metric #87042
Conversation
analytics.record( | ||
"issue.resolved", | ||
project_id=group.project.id, | ||
default_user_id=organizations[0].get_default_owner().id, | ||
default_user_id=default_user_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this field allowed to be falsey? Assuming this is the correct definition, analytics for this event appears to have it defaulted to required:
analytics.Attribute("default_user_id"), |
Maybe we can toggle this to required = False
in this PR as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I have no idea. analytics
is amplitude, right? I've never used it - didn't even know those metrics came with a schema! Happy to make that change after the meeting I'm about to run into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so! And sounds good, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to figure out if setting the value to None
was the same as not providing a value ("not required" and "can be null" could conceivably mean different things), and noticed that you also need to specify type, which might have had to change... So in the end I decided it was easier to leave the schema as is and just set the value to <unknown>
. (I know id
is a number, but it must get stringified, because the default type is str
and that property in the schema (to which you linked) doesn't specify type, so it must also be str
. That said, to satisfy mypy, I had to explicitly stringify it.)
LMK if that solution works, and if not, I'll figure out about the null vs missing question and modify the schema appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call out, that works! We can circle back on this if we notice any issues with analytics for this event.
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #87042 +/- ##
==========================================
- Coverage 87.78% 87.74% -0.05%
==========================================
Files 9853 9847 -6
Lines 558951 557050 -1901
Branches 21966 21966
==========================================
- Hits 490686 488778 -1908
- Misses 67835 67842 +7
Partials 430 430 |
c40d3ee
to
702219f
Compare
702219f
to
49a13bb
Compare
49a13bb
to
dd44fd2
Compare
In our `sync_status_inbound` integrations task, we record a metric which includes the user id of the org's owner. This can crash if we can't find an owner - in `Organization.get_default_owner`, we try to return the first owner, but that raises an index error if the owner list is empty. Since the value is only being used for a metric, we don't want retrieving it to make the whole task error out. This therefore wraps the code getting the value in a `try-except`, and sets the value to `None` if the index error is raised. Since this is really just a bandaid (orgs should always have an owner, shouldn't they?), it also adds a TODO for investigating how there can be no owners. Fixes https://sentry.sentry.io/issues/4069184744.
In our
sync_status_inbound
integrations task, we record a metric which includes the user id of the org's owner. This can crash if we can't find an owner - inOrganization.get_default_owner
, we try to return the first owner, but that raises an index error if the owner list is empty.Since the value is only being used for a metric, we don't want retrieving it to make the whole task error out. This therefore wraps the code getting the value in a
try-except
, and sets the value toNone
if the index error is raised. Since this is really just a bandaid (orgs should always have an owner, shouldn't they?), it also adds a TODO for investigating how there can be no owners.Fixes https://sentry.sentry.io/issues/4069184744.