Skip to content

fix(teams): handle API errors and cleanup loading state in useTeam - #21289

Open
FrancescoCastaldi wants to merge 1 commit into
PostHog:masterfrom
FrancescoCastaldi:fix/team-page-unhandled-error-21280
Open

FrancescoCastaldi wants to merge 1 commit into
PostHog:masterfrom
FrancescoCastaldi:fix/team-page-unhandled-error-21280

Conversation

@FrancescoCastaldi

Copy link
Copy Markdown

Summary

Fixes #21280

When /api/teams fails or returns a non-200 response (such as a 500 error page or network block), useTeam previously threw an unhandled rejection, causing team pages (/teams/<slug>) to stay indefinitely in their loading state because setLoading(false) was never reached.

Changes

  1. Added status check (if (!res.ok) throw new Error(...)) in fetchTeam before calling res.json().
  2. Handled error catching inside fetchTeam with setTeam(undefined) to allow team pages and roster views to exit cleanly into their fallback state.
  3. Updated useEffect to use .finally(() => setLoading(false)) ensuring the loading state is always dismissed on both success and failure.

Testing

  • Verified successful team queries resolve as expected.
  • Verified non-200 and network failure paths catch cleanly and toggle loading to false.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T14:46:39.783428Z 43608a9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added the website About the website (beyond just landing pages) label Oct 16, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in two weeks! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@github-actions github-actions Bot added the stale This pull request has been marked as stale and will be closed soon automatically label Nov 2, 2026
@andyvan-ph
andyvan-ph requested a review from a team November 2, 2026 10:58
@andyvan-ph andyvan-ph moved this from Backlog to Awaiting review in PostHog.com planning Nov 2, 2026
@github-actions github-actions Bot removed the stale This pull request has been marked as stale and will be closed soon automatically label Nov 3, 2026
@andyvan-ph
andyvan-ph requested review from a team and removed request for a team November 5, 2026 11:13
@FrancescoCastaldi
FrancescoCastaldi force-pushed the fix/team-page-unhandled-error-21280 branch from 43608a9 to 6bc4959 Compare November 9, 2026 10:11
@signed-commit-check

Copy link
Copy Markdown

A quick word from the signature department

Hey @FrancescoCastaldi, thanks for the PR! GitHub couldn't verify the signature on this commit:

  • 6bc4959: Unsigned

PostHog requires verified commit signatures before merging. So we've built a bot to do the nagging. You're talking to it.

Let's get this verified

If signing isn't set up yet, follow our signing guide or GitHub's guide.

Already signed? Make sure GitHub recognizes your key. SSH keys must be registered as a Signing Key, not only as an Authentication Key.

Once signing is set up, if the unsigned commit is your latest commit, run:

git commit --amend --no-edit -S
git push --force-with-lease

Those commands fix only your latest commit. Older unsigned commits need signing too. Coordinate with anyone else using the branch before rewriting its history.

Save your future self another visit from me:

git config --local commit.gpgsign true

That enables signing for future commits; it doesn't sign existing ones. A Signed-off-by line isn't a cryptographic signature.

I'll check again after your next push and update this comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

website About the website (beyond just landing pages)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Team pages throw unhandled errors and can stay loading when the team API request fails

1 participant