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: filter out undefined values for building workspace owners array #3305

Merged
merged 1 commit into from
May 2, 2024

Conversation

brandonroberts
Copy link
Contributor

@brandonroberts brandonroberts commented May 2, 2024

Description

  • Fixes a bug where a workspaces has owners and viewers, which causes an error in getServerSideProps when undefined is returned in the owners array

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings

Steps to QA

  1. Navigate to a workspace with an owner and viewer
  2. Go to a contributor insight
  3. Note the page loads correctly

Tier (staff will fill in)

  • Tier 1
  • Tier 2
  • Tier 3
  • Tier 4

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

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

Copy link

@github-actions github-actions 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 Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Copy link

netlify bot commented May 2, 2024

Deploy Preview for oss-insights ready!

Name Link
🔨 Latest commit eb3ebe0
🔍 Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/6633dd40f776bb0009fd0022
😎 Deploy Preview https://deploy-preview-3305--oss-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 2, 2024

Deploy Preview for design-insights ready!

Name Link
🔨 Latest commit eb3ebe0
🔍 Latest deploy log https://app.netlify.com/sites/design-insights/deploys/6633dd4045bf07000873e397
😎 Deploy Preview https://deploy-preview-3305--design-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonroberts brandonroberts requested a review from a team May 2, 2024 18:48
Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

when undefined is returned in the owners array

That's surprising since my assumption was that the "members": [] would always have at least one member/owner. I thought we had blocked removing all members from a workspace (or at least owners could not remove themselves)

Or maybe it's something else? I'm very curious why this would be getting undefined in the members array.

@brandonroberts
Copy link
Contributor Author

brandonroberts commented May 2, 2024

when undefined is returned in the owners array

That's surprising since my assumption was that the "members": [] would always have at least one member/owner. I thought we had blocked removing all members from a workspace (or at least owners could not remove themselves)

Or maybe it's something else? I'm very curious why this would be getting undefined in the members array.

The data is correct

[
  { "login": "me", "role": "owner" },
  { "login": "you", "role": "viewer" },
]
  const owners = Array.from(workspaceMembers?.data || [], (member: { role: string; member: Record<string, any> }) => {
    if (member.role === "owner") {
      return member.member.login;
    }
  }); // without the filter

['me', undefined]

If its an owner, the login is returned. If its not, undefined is returned. Then when getServersideProps tries to serialize the data, if fails

Copy link
Member

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

🚢

Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

Thanks for explaining !!!!!!!!!! 🧠 ◀️ 🥇

@brandonroberts brandonroberts merged commit bd4e1fe into beta May 2, 2024
19 checks passed
@brandonroberts brandonroberts deleted the fix-owners-filter branch May 2, 2024 20:10
open-sauced bot pushed a commit that referenced this pull request May 2, 2024
## [2.24.0-beta.4](v2.24.0-beta.3...v2.24.0-beta.4) (2024-05-02)

### 🐛 Bug Fixes

* filter out undefined values for building workspace owners array ([#3305](#3305)) ([bd4e1fe](bd4e1fe))
open-sauced bot pushed a commit that referenced this pull request May 2, 2024
## [2.24.0](v2.23.0...v2.24.0) (2024-05-02)

### 🍕 Features

* implement `ContributorsChart` for repo pages ([#3302](#3302)) ([b52b0e6](b52b0e6))
* implemented the StarSearch feedback component ([#3298](#3298)) ([1297274](1297274))

### 🐛 Bug Fixes

* explore links 404 ([#3297](#3297)) ([ba05a16](ba05a16))
* filter out undefined values for building workspace owners array ([#3305](#3305)) ([bd4e1fe](bd4e1fe))
* return 404 on invalid workspace ID ([#3301](#3301)) ([d09c229](d09c229))
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.

None yet

4 participants