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

Add propertyExists() guardian #14

Closed
wants to merge 3 commits into from
Closed

Conversation

gomorizsolt
Copy link
Collaborator

@gomorizsolt gomorizsolt commented Jul 7, 2020

This PR adds a propertyExists() function to ensure a property on a target object.

Properties must be ensured and fail early before destructuring them, otherwise runtime errors may occur.
Copy link
Member

@thisismydesign thisismydesign left a comment

Choose a reason for hiding this comment

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

Would this fail the job? Right now it's failing every time too which I want to avoid. I assume there's a happy path that wasn't covered.

@gomorizsolt
Copy link
Collaborator Author

Right now it's failing every time too which I want to avoid.

With what the job is failing? As for the question, returning with Promise.reject() would definitely fail the job.

@gomorizsolt
Copy link
Collaborator Author

We can replace these return statements with Promise.resolve() but this way the job wouldn't fail and therefore we wouldn't be notified if there's a missing property on an object.

@gomorizsolt
Copy link
Collaborator Author

Tweaked the code a little bit: e308886

Given that we're not aware of the exact reason why certain properties are missing on the responses, I'd let the job fail with meaningful error messages. This way we can trace back the errors and act in response to them.

@thisismydesign
Copy link
Member

What's the plan with this? We shouldn't release another broken version. We should reproduce and fix the issue.

@gomorizsolt
Copy link
Collaborator Author

What's the plan with this? We shouldn't release another broken version. We should reproduce and fix the issue.

Alright, makes sense. Then I'll need some info as I can't reproduce the issue. Created an instance of the bot there's no error in my case.

Since you also reported the error, could you take a look at your notifications? Isn't there e.g. a system-level notification which doesn't belong to a user?

#14 (comment)

This comment is left unanswered.

@thisismydesign
Copy link
Member

thisismydesign commented Jul 10, 2020

Right now it's failing every time too which I want to avoid.

With what the job is failing? As for the question, returning with Promise.reject() would definitely fail the job.

I meant currently the job is failing, but the goal is not to have it fail.

Since you also reported the error, could you take a look at your notifications? Isn't there e.g. a system-level notification that doesn't belong to a user?

Started failing on July 1st 2020 12:04am with this: mbrn/material-table#1592.
The initial issue was fixed but the job kept failing - I'd assume it was the same notification causing it.

Stopped failing July 8th 2020 6:05pm - because the notification is now more than 7 days old. If you extend the 7 days I expect you can reproduce the issue.

@gomorizsolt
Copy link
Collaborator Author

Thanks for this info. This way the error is reproducible but in my case the job fails because of a release notification. I've inspected the response and it seems there's no user property on data but author in the case of releases.

I'd propose adding the following:

const releaseNotification = data.author && !data.user;

if (releaseNotification) {
   // terminate the promise
}

I'd assume it was the same notification causing it.

Yea, it's most likely because of that. But it's interesting because if the comments are listed for that issue specifically then each object contains the user property (even the automated bot message):

{
   "url":"https://api.github.com/repos/mbrn/material-table/issues/comments/652067096",
   "html_url":"https://github.com/mbrn/material-table/issues/1592#issuecomment-652067096",
   "issue_url":"https://api.github.com/repos/mbrn/material-table/issues/1592",
   "id":652067096,
   "node_id":"MDEyOklzc3VlQ29tbWVudDY1MjA2NzA5Ng==",
   "user":{
      "login":"stale[bot]",
      "id":26384082,
      "node_id":"MDM6Qm90MjYzODQwODI=",
      "avatar_url":"https://avatars3.githubusercontent.com/in/1724?v=4",
      "gravatar_id":"",
      "url":"https://api.github.com/users/stale%5Bbot%5D",
      "html_url":"https://github.com/apps/stale",
      "followers_url":"https://api.github.com/users/stale%5Bbot%5D/followers",
      "following_url":"https://api.github.com/users/stale%5Bbot%5D/following{/other_user}",
      "gists_url":"https://api.github.com/users/stale%5Bbot%5D/gists{/gist_id}",
      "starred_url":"https://api.github.com/users/stale%5Bbot%5D/starred{/owner}{/repo}",
      "subscriptions_url":"https://api.github.com/users/stale%5Bbot%5D/subscriptions",
      "organizations_url":"https://api.github.com/users/stale%5Bbot%5D/orgs",
      "repos_url":"https://api.github.com/users/stale%5Bbot%5D/repos",
      "events_url":"https://api.github.com/users/stale%5Bbot%5D/events{/privacy}",
      "received_events_url":"https://api.github.com/users/stale%5Bbot%5D/received_events",
      "type":"Bot",
      "site_admin":false
   },
   "created_at":"2020-06-30T21:56:02Z",
   "updated_at":"2020-06-30T21:56:02Z",
   "author_association":"NONE",
   "body":"This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.\n"
}

I'm therefore not entirely sure if that's where the issue stems from. Didn't you receive a release notification on 2020-06-30?

I'm open to discussing this.

@gomorizsolt
Copy link
Collaborator Author

As a side note, the user object above has a type property which we can make use of to detect bots.

@thisismydesign
Copy link
Member

I like the proposal. I've received a release notification for fresh-bot in fact :D And the time matches, so yes that could've caused the issue.

I also like the type field proposal, could you create an issue for that please?

@gomorizsolt
Copy link
Collaborator Author

I also like the type field proposal, could you create an issue for that please?

Yea, sure: #17

@gomorizsolt
Copy link
Collaborator Author

gomorizsolt commented Jul 17, 2020

Closed in favour of #18.

@gomorizsolt gomorizsolt deleted the add-property-guardians branch July 17, 2020 08:51
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