René's URL Explorer Experiment


Title: fix(webapp): don't apply an invite's role to an existing org member by claude[bot] · Pull Request #4409 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix(webapp): don't apply an invite's role to an existing org member by claude[bot] · Pull Request #4409 · triggerdotdev/trigger.dev

X Title: fix(webapp): don't apply an invite's role to an existing org member by claude[bot] · Pull Request #4409 · triggerdotdev/trigger.dev

Description: Requested via Slack thread Summary Accepting an old invitation could change the role of someone who was already in the organization. A long-pending invite can carry a lower role than the member has since been promoted to, so accepting it was a silent demotion. When the accepting user was the organization's only Owner, the role layer refused that demotion, and the refusal (an expected, protective outcome) was logged as an error. An invitation now only sets a role on a membership the accept actually created, and people who are already in an organization are skipped when invitations are sent. How acceptInvite already skipped the OrgMember create when it found an existing membership, but the rbac.setUserRole call below it was gated only on invite.rbacRoleId. It now also tracks whether this accept created the membership. A create that loses the unique-constraint race counts as pre-existing, since whichever flow won it owns that membership's role. Skipping existing members outright would regress one case: a member with no RBAC role at all would never receive the invitation's role. ensureOrgMember handles that with healMissingRoleAssignment, which fills in a null role but never overwrites a real one, so assignInviteRbacRole takes the same gate. An established role is never touched; an absent one is filled in. assignInviteRbacRole branches on the result's machine-readable code instead of logging every refusal at error. last_owner goes to logger.info, matching the two directory-sync role paths; everything else, including a refusal that carries no code, goes to logger.warn. The helper is best-effort and never throws, so no outcome it produces warrants error. No string matching on the error text is involved. inviteMembers resolves the organization's members by email and skips those addresses before creating invites. The invite table's @@unique([organizationId, email]) only dedupes pending invites, so it could never catch this. Invite surfaces Skipping addresses means a batch can now come back empty, and neither caller handled that: The dashboard action built its redirect from invites[0].organization, so a batch where every address was skipped threw a TypeError that reached the admin as a raw error string. It also reported the submitted count rather than the created one. It now names what it skipped ("No invitations sent: 1 already a member of this organization") and counts what it actually created. The invites API derived alreadyInvited as "everything not created", so an existing member was reported as though they had already been invited. inviteMembers now returns the two groups separately and the endpoint reports alreadyMembers alongside alreadyInvited. Testing apps/webapp/test/member.server.test.ts passes 16/16 locally, up from 12. Getting there needed a harness fix. The ~/db.server mock did not export Prisma, so any code reaching PrismaNamespace.PrismaClientKnownRequestError threw before it could branch, leaving every duplicate-key path in member.server.ts unreachable from tests. The mock now re-exports the real Prisma, and there is a case covering the pending-invite skip. New cases: the invite role is applied when the accept creates the membership; it is not applied when the member already has a role; it is applied when an existing member has no role assigned; the organization is still joined when the assignment is refused with last_owner; and inviteMembers reports members separately from pending invites. Forcing the gate off fails exactly the "already has a role" case, so the coverage is load-bearing. pnpm run typecheck --filter webapp and oxfmt --check both pass. Changelog Accepting an old invitation could change the role of someone who was already in the organization. An invitation now leaves an existing member's role untouched, people who are already in an organization are no longer sent invitations to it, and the invite form says which addresses it skipped instead of failing with an unhelpful error. ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention. I ran and tested the code works. Screenshots No visual changes. The invite form's toast copy changes, as described above.

Open Graph Description: Requested via Slack thread Summary Accepting an old invitation could change the role of someone who was already in the organization. A long-pending invite can carry a lower role than the member has...

X Description: Requested via Slack thread Summary Accepting an old invitation could change the role of someone who was already in the organization. A long-pending invite can carry a lower role than the member has...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4409

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:2873213e-d44e-c790-04fa-087efb9e661f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD75A:2884AC:69BF:9785:6AFB08A6
html-safe-nonce216ed2531faaa8e066c5801b7827e06d0d82f2672667e38add817b5f218fa008
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzVBOjI4ODRBQzo2OUJGOjk3ODU6NkFGQjA4QTYiLCJ2aXNpdG9yX2lkIjoiOTAzNTYwMDQ2MjIyMDAzNjI2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac86e5b98b32c012723a92058fa8f021e9204254dccf4be3f792322a451d515bb7
hovercard-subject-tagpull_request:4152992743
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4409/files
twitter:imagehttps://avatars.githubusercontent.com/in/1236702?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/in/1236702?s=400&v=4
og:image:altRequested via Slack thread Summary Accepting an old invitation could change the role of someone who was already in the organization. A long-pending invite can carry a lower role than the member has...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None76fb13cb43f1834708971f45a9cfcab5df3177a7582086613d7cdc6e98c4bfde
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseafc998826cdd963c8f91a96ae5372809ab5e296b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/4409/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4409%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4409%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
matt-aitkenhttps://github.com/matt-aitken
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
claude/fix-invite-role-demotionhttps://github.com/triggerdotdev/trigger.dev/tree/claude/fix-invite-role-demotion
Conversation 1 https://github.com/triggerdotdev/trigger.dev/pull/4409
Commits 3 https://github.com/triggerdotdev/trigger.dev/pull/4409/commits
Checks 40 https://github.com/triggerdotdev/trigger.dev/pull/4409/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4409/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
fix(webapp): don't apply an invite's role to an existing org member https://github.com/triggerdotdev/trigger.dev/pull/4409/files#top
Show all changes 3 commits https://github.com/triggerdotdev/trigger.dev/pull/4409/files
9b93099 fix(webapp): don't apply an invite's role to an existing org member claude Jul 28, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4409/commits/9b930999ad1f4f8ac7315c3ccef1eb9eb9b78bbd
3ad1493 chore(webapp): strip explanatory comments from the invite role fix matt-aitken Jul 28, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4409/commits/3ad14936c991c544ecadbba44e82d31e98887519
9b60a42 fix(webapp): report skipped invites instead of failing, and heal a me… matt-aitken Jul 28, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4409/commits/9b60a421511754ea4094ff6396e3dbe59493c934
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4409/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
fix-invite-role-change-for-existing-members.md https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-010d1ae78f8b32fb94e17110c9fc4a4d301f3a0bf44aa38b2376b70944a26537
member.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
route.tsx https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
api.v1.orgs.$orgParam.invites.ts https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-99344ef4e76b5fe1e1613f362eca42384ad5ec0635f6775785a064260c55f5c9
member.server.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-3a49d6261f791d109020fcab719bd95aea3611f207c4f52a331f155aa3481c2b
.server-changes/fix-invite-role-change-for-existing-members.mdhttps://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-010d1ae78f8b32fb94e17110c9fc4a4d301f3a0bf44aa38b2376b70944a26537
View file https://github.com/triggerdotdev/trigger.dev/blob/9b60a421511754ea4094ff6396e3dbe59493c934/.server-changes/fix-invite-role-change-for-existing-members.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4409/{{ revealButtonHref }}
apps/webapp/app/models/member.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
View file https://github.com/triggerdotdev/trigger.dev/blob/9b60a421511754ea4094ff6396e3dbe59493c934/apps/webapp/app/models/member.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4409/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-d65725675f3276afd917d8f8499105abaddaa9fbb2137271110b7bde3a97e8ed
apps/webapp/app/routes/_app.orgs.$organizationSlug.invite/route.tsxhttps://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
View file https://github.com/triggerdotdev/trigger.dev/blob/9b60a421511754ea4094ff6396e3dbe59493c934/apps/webapp/app/routes/_app.orgs.%24organizationSlug.invite/route.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4409/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-ade78f52ea6f95c2f4092cd8b40057d2e050e18cdd5cf2aea0d7553a677ea5a9
apps/webapp/app/routes/api.v1.orgs.$orgParam.invites.tshttps://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-99344ef4e76b5fe1e1613f362eca42384ad5ec0635f6775785a064260c55f5c9
View file https://github.com/triggerdotdev/trigger.dev/blob/9b60a421511754ea4094ff6396e3dbe59493c934/apps/webapp/app/routes/api.v1.orgs.%24orgParam.invites.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4409/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-99344ef4e76b5fe1e1613f362eca42384ad5ec0635f6775785a064260c55f5c9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-99344ef4e76b5fe1e1613f362eca42384ad5ec0635f6775785a064260c55f5c9
https://github.com/triggerdotdev/trigger.dev/pull/4409/files#diff-99344ef4e76b5fe1e1613f362eca42384ad5ec0635f6775785a064260c55f5c9
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4409/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.