fix(organization): drop the redundant id input from org update/delete tools - #6541
fix(organization): drop the redundant id input from org update/delete tools#6541Tyagiquamar wants to merge 2 commits into
Conversation
|
@Tyagiquamar instead of checking |
|
Done in 10aa5a3 — much cleaner this way, thanks. Both tools now drop |
… tools Per review on decocms#6541: the target organization is always the one resolved from the URL path, so the id parameter could only ever carry a value the server already knows. Remove it from both input schemas and take the org from requireOrganization(ctx) instead of comparing ids (supersedes the id-guard approach that landed via decocms#6537). tools-rest parses with a non-strict z.object, so agents still sending id keep working. Verified: bun test for both tool files (6 pass), tsc --noEmit on shared and api, biome format clean. apps/web tsc has a pre-existing prosemirror-model duplicate-version error that reproduces on pristine upstream/main.
10aa5a3 to
074cddc
Compare
|
Small correction to my note above: the guard this PR originally added landed upstream independently via #6537, so I rebased onto current main and squashed — the change is now 074cddc (same content: both tools drop |
|
Merged the latest main: the already-archived no-op guard is adopted in ORGANIZATION_DELETE, and ORGANIZATION_UPDATE keeps merging into existing metadata so unrelated keys are preserved. Both tools still take the organization from requireOrganization(ctx) with the id input dropped. The organization tool tests pass after the merge. |
Problem
ORGANIZATION_UPDATEtookidas the org to update but never checked it againstctx.organization?.id(the path-resolved, membership-verified org). A caller authenticated against org A could passinput.idfor org B and reachboundAuth.organization.updatewith an org they may have zero membership in. As with ORGANIZATION_DELETE before #6501, Better Auth's ownupdateOrganizationre-checks permission for the target org, so this is not a live bypass today — but it left the tool one vendored-dependency behavior away from one.Fix
Per review, the parameter is gone rather than guarded: both
ORGANIZATION_UPDATEandORGANIZATION_DELETEdropidfrom their input schemas and take the org fromrequireOrganization(ctx), which is already resolved from the URL path — so there is nothing left to compare and nothing to spoof.tools-rest.tsparses with a non-strictz.object, so any agent still sendingidkeeps working and just gets it stripped. The sharedtool-io.tstypes and the settings UI'sORGANIZATION_DELETEcall were updated to match.Testing
bun test apps/api/src/tools/organization/update.test.ts apps/api/src/tools/organization/delete.test.ts→ 6 pass, 0 fail (cases now assert the update targets the org resolved from the request context).tsc --noEmitonpackages/shared,apps/api,apps/web→ exit 0.biome formaton touched files → clean.Summary by cubic
Drops the
idinput fromORGANIZATION_UPDATEandORGANIZATION_DELETE, so the target organization always comes from the URL-resolved request context instead of client-supplied input.ORGANIZATION_DELETEis now idempotent: deleting an already archived organization returns success without updating it.requireOrganization(ctx), leaving no id to compare or spoof.idkeep working becausetools-restparses non-strictly and strips the field.tool-iotypes were updated to match.Written for commit 91969ab. Summary will update on new commits.