Repository navigation
fix(server): let a workspace whose plan has ended delete a brand - #1630
Merged
Merged
Conversation
Ansvisor's decision (2026-10-27), the product call on ansvisor#1589's follow-up 3: DELETE /brands/:id only removes what the person gave us, so it joins a new DATA_REMOVAL list, open whatever the plan. Admins only, as before; every other brand write stays closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 12 tasks
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
What I checked:
- What opens.
DATA_REMOVALhas one entry,DELETE /brands/:id(with or without a trailing slash).isOpenis read only afterdecodeToken, as forCOST_STOPPING, so a request with no signed-in person is still refused. The regex is case-sensitive and Express routing isn't, soDELETE /Brands/xstill gets the 402. That's the safe way round. The test also coversPOST /brands,PUT/PATCH /brands/:id,DELETE /brands/b1/domains/d1andDELETE /brands, which all still get the 402. - Still admins only, still the person's own brand. The route itself hasn't changed. It checks
assertBrandAccess(brand in the caller's organization, 404/403 otherwise), thenprofiles.role === 'admin'(403 otherwise). The middleware was the only thing standing between an ended workspace and that check, so the rules for who may delete stay the same. - No paid work.
deleteBranddeletes in batches (delete_brand_results_batch), then deletes the brand row. Nothing calls a model, Cloro, Scrape.do, DataForSEO or a store. The triggers the cascade fires are database-only: the usage counters, thecatalog_sources_forgetproduct cleanup, and the citation-rollup queue, which skips a brand that no longer exists. A second click joins the run already going (inProgress). - Tests. On this branch,
subscription.test.jspasses (25 tests). With main'ssubscription.jsunder the same tests, the new test fails. - Merge. Clean on main 3f6a4d4. Also clean with #1612 and #1613, the web halves.
Before and after the API deploy: server only, so merging changes nothing until the API is deployed. The API in production predates #1589, so brand deletion works there today. Deploy this with #1589, not after it: an API with #1589 and without this answers 402 to an ended workspace's Delete brand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A workspace whose plan has ended may delete a brand without buying first. This is the product call left open in your #1589 follow-up 3. Ansvisor decided on 2026-10-27 that deleting a brand only removes what the person gave us, so leaving needs no purchase.
DELETE /brands/:idjoins a newDATA_REMOVALlist inrequireActiveSubscription, open whatever the plan. Only admins can delete, as before.POST /brands,PUTandPATCH /brands/:id, and anyDELETEunder a brand (for example/brands/b1/domains/d1).This commit was meant for #1611. I pushed it a few minutes after you merged #1611, so it never reached main. It's a cherry-pick of that commit (6cc1c99) onto today's main. The web side is in #1612 (the Delete button stays open while read-only) and #1613 (
deleteBrandstays in the coverage test's open list). Until this lands, that button answers 402.Related issue
None. Follows #1589 and #1611 (your follow-up 3), and Ansvisor's product decision (2026-10-27).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/middleware/subscription.test.jssubscription_status = canceled:DELETE /api/brands/:iddeletes the brand;POST /api/brandsandPATCH /api/brands/:idstill answer 402.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — no web changeyarn typecheckpasses (run fromweb/) — no web changeyarn format:checkpasses (run fromweb/) — no web changeAlso run in
server/:npm run format,npm run lintandnpm test(3,339 tests).🤖 Generated with Claude Code