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

[sentry fix] handle undefined createdBy case #7818

Merged
merged 1 commit into from
Oct 18, 2024
Merged

[sentry fix] handle undefined createdBy case #7818

merged 1 commit into from
Oct 18, 2024

Conversation

ijreilly
Copy link
Collaborator

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request modifies the CreatedByPreQueryHook class to handle cases where datum.createdBy is undefined, addressing a Sentry error in the production environment.

  • Added optional chaining (?.) in created-by.pre-query-hook.ts to safely access datum.createdBy.name
  • Introduced a fallback mechanism to use createdBy data when datum.createdBy is undefined or lacks a name
  • Modified the condition to set createdBy for each datum, improving robustness
  • Preserved the existing source from datum.createdBy if available, ensuring data integrity
  • Potential for further optimization by refactoring the createdBy assignment logic

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -101,7 +101,7 @@ export class CreatedByPreQueryHook implements WorkspaceQueryHookInstance {

for (const datum of payload.data) {
// Front-end can fill the source field
if (createdBy && (!datum.createdBy || !datum.createdBy.name)) {
if (createdBy && (!datum.createdBy || !datum.createdBy?.name)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think there is a redundant check here, wdyt?
Could be

if (createdBy && (!datum.createdBy?.name))

@Weiko Weiko merged commit 5a23d1e into main Oct 18, 2024
8 checks passed
@Weiko Weiko deleted the fix-sentry branch October 18, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants