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: update-open-sauced-goals-cache bug #39

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

takanome-dev
Copy link

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Description

This PR fixes the bug in update-open-sauced-goals-cache.js. If open-sauced-goals repo (issue name) do not conform to repo full name conventions, the goal caching action will fail.

Related Tickets & Documents

Fixes #38

Mobile & Desktop Screenshots/Recordings

This is my goals repo. As you can see, since the last 3 days the action keeps failing due to renovatebot Dependency Dashboard issue. But now everything looks good.

goals_caching

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ docs.opensauced.pizza
  • πŸ• dev.to/opensauced
  • πŸ“• storybook
  • πŸ™… no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

@bdougie
Copy link
Member

bdougie commented Jun 1, 2022

Thanks for the PR @takanome-dev. Can you share what you changed in the description. At first glance it looks like an early return but it's all hidden amongst formatting changes.

@takanome-dev
Copy link
Author

This is what I added:

async function getRepoGoals(issues){
  return Promise.all(
    issues.map(async issue => {
      // all goal issues follow the "owner/repo" format
      let [owner, name] = issue.title.split("/");
+    if (!owner || !name) return;
    }
  )
}

@mtfoley
Copy link
Contributor

mtfoley commented Jun 1, 2022

I think the early return will break production, I'd suggest filtering prior to the Promise.all.

@takanome-dev the issue you're seeing here is probably the result of the early return statement:

image from the bug you filed this morning:
screenshot of console error

affected app code: https://github.com/open-sauced/open-sauced/blob/4a26b94eaa1a1094ee0dd0d7ca76ead50da2acc4/src/components/RepositoryGoals.jsx#L52-L57

null where an object should be: https://github.com/TAKANOME-DEV/open-sauced-goals/blob/main/data.json#L8

@0-vortex
Copy link
Contributor

0-vortex commented Jun 1, 2022

This is what I added:

async function getRepoGoals(issues){
  return Promise.all(
    issues.map(async issue => {
      // all goal issues follow the "owner/repo" format
      let [owner, name] = issue.title.split("/");
+    if (!owner || !name) return;
    }
  )
}

Please use the integration verification rather than owner plus repo, the actual bug is having issues added by other integrations, it doesn't solve the use case where that integration would add something with a slash in the middle /. Happy to have both solutions in there, however they need some refining.

It would also be great if you limited you pull request to the actual code change rather than reformat the code using prettier. Main motivation for that was that this repo is fairly old and it should only tackle github application integrations for the open-sauced org, tooling and contribution improvements were not added yet. It is unlikely that this repo would take many contributions due to the level of complexity involved in testing :D

@takanome-dev
Copy link
Author

Thanks for feedbacks I will work on it ASAP πŸ‘

@takanome-dev
Copy link
Author

takanome-dev commented Jun 1, 2022

I made these changes:

async function getRepoGoals(issues){
  return Promise.all(
    issues.map(async issue => {
      // all goal issues follow the "owner/repo" format
      let [owner, name] = issue.title.split("/");
-    if (!owner || !name) return;
    }
  )
}

try {
  stagedIssues = await octokit.rest.issues.listForRepo({
    owner: login,
    repo: "open-sauced-goals",
  });
  console.log("stagedIssues", stagedIssues);
-   repoIssues = await octokit.paginate(stagedIssues);
+  const issues = await octokit.paginate(stagedIssues);
+  // filter issues created by bots
+  repoIssues = issues.filter((repoIssue) => repoIssue.user.type !== "Bot");
} catch (err) {
  console.log(err);
}

@takanome-dev
Copy link
Author

Sorry about these commits I had some conflicts to resolve πŸ˜“

@0-vortex
Copy link
Contributor

0-vortex commented Jun 2, 2022

Sorry about these commits I had some conflicts to resolve πŸ˜“

No worries, we have squash pull requests for exactly that matter! πŸ•

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.

Bug: need to validate goals prior to network calls
4 participants