sentry icon indicating copy to clipboard operation
sentry copied to clipboard

fix(feedback): check if event tags exist before accessing property

Open michellewzhang opened this issue 1 year ago • 5 comments

fixes https://github.com/getsentry/sentry/issues/70887

michellewzhang avatar May 16 '24 09:05 michellewzhang

Do the TS types say the correct thing here? If not then there might be other spots in the app that are in trouble too

the event data is built off the issues Event type which doesn't have tags as optional

michellewzhang avatar May 16 '24 13:05 michellewzhang

the event data is built off the issues Event type which doesn't have tags as optional

Why are we getting tags = null then? Should there be typecheck errors somewhere?

aliu39 avatar May 16 '24 17:05 aliu39

Hope it's okay for me to wade in - it seems like there are other spots in the same file doing a null check on tags even though the types suggest there isn't a need

        {!crashReportId || (crashReportId && url) ? (
          <Section icon={<IconLink size="xs" />} title={t('URL')}>
            <TextCopyInput size="sm">
              {eventData?.tags ? (url ? url.value : t('URL not found')) : ''}
            </TextCopyInput>
          </Section>
        ) : null}

I'm the person who reported https://github.com/getsentry/sentry/issues/70887 and if I can be helpful by providing more context (like the actual content of eventData that's failing for me, in case that would point to a different cause of the problem) please let me know.

joshacheson avatar May 16 '24 20:05 joshacheson

I'm the person who reported #70887 and if I can be helpful by providing more context (like the actual content of eventData that's failing for me, in case that would point to a different cause of the problem) please let me know.

@joshacheson if you have the content that eventData failed on, that would be helpful!

michellewzhang avatar May 17 '24 04:05 michellewzhang

Here's eventData. I've scrubbed some fields. Perhaps it's also relevant (at least it stood out to me) that it appears this eventData object came from a call to /api/0/. It seemed like an odd api to hit to get something used specifically on the user feedback page but of course I know nothing about how the Sentry app is built.

{
    "version": "0",
    "auth": null,
    "user": {
        "id": "3",
        "name": "{{scrubbed}}",
        "username": "fee7617f6acd4565b3757ab454064eea",
        "email": "{{scrubbed}}",
        "avatarUrl": "{{scrubbed}}",
        "isActive": true,
        "hasPasswordAuth": false,
        "isManaged": false,
        "dateJoined": "2016-05-20T19:05:28.632844Z",
        "lastLogin": "2024-05-16T17:53:22.766629Z",
        "has2fa": false,
        "lastActive": "2024-05-17T17:15:40.537105Z",
        "isSuperuser": false,
        "isStaff": false,
        "experiments": {},
        "emails": [
            {
                "id": "26",
                "email": "{{scrubbed}}",
                "is_verified": true
            }
        ],
        "options": {
            "theme": "light",
            "language": "en",
            "stacktraceOrder": 2,
            "defaultIssueEvent": "recommended",
            "timezone": "Canada/Eastern",
            "clock24Hours": false,
            "issueDetailsNewExperienceQ42023": false
        },
        "flags": {
            "newsletter_consent_prompt": false
        },
        "avatar": {
            "avatarType": "gravatar",
            "avatarUuid": null,
            "avatarUrl": "{{scrubbed}}"
        },
        "identities": [
            {
                "id": "442",
                "name": "{{scrubbed}}",
                "organization": {
                    "slug": "{{scrubbed}}",
                    "name": "{{scrubbed}}"
                },
                "provider": {
                    "id": "active-directory",
                    "name": "Active Directory"
                },
                "dateSynced": "2024-05-17T16:08:00.009973Z",
                "dateVerified": "2024-05-16T17:53:22.596516Z"
            }
        ]
    }
}

joshacheson avatar May 17 '24 17:05 joshacheson

@michellewzhang this good to merge?

aliu39 avatar Jun 05 '24 18:06 aliu39