Skip to content

fix(bulk-upload): re-run existing personal drafts in place instead of duplicating#13

Closed
rayopavri wants to merge 1 commit into
mainfrom
claude/loving-euler-eMTMs
Closed

fix(bulk-upload): re-run existing personal drafts in place instead of duplicating#13
rayopavri wants to merge 1 commit into
mainfrom
claude/loving-euler-eMTMs

Conversation

@rayopavri

Copy link
Copy Markdown
Owner

Problem

Bulk-upload was re-processing URLs that already had a bundle (e.g. hashicorp.com), producing duplicate draft rows on every run.

The dedup only skips a URL when the existing bundle is published or pending_review (route.ts). personal drafts were deliberately left "re-generatable" so a junk draft couldn't block a URL forever — but the pipeline then INSERTs a new bundle rather than updating the existing draft, so duplicates pile up. The affected bundles render publicly (the slug query only hides archived) and show the AUTO-DISCOVERED badge (isCurated=false), which is the tell that they never auto-published.

Fix

Add a third outcome — re-run in place — between "skip" and "insert new":

  • published / pending_reviewskip (unchanged)
  • personal (draft) → re-run in place: the job is enqueued with targetBundleId set, so writeDraftBundle UPDATEs the existing draft instead of inserting a duplicate. If several stale drafts exist for the same normalized URL, the newest is targeted and the older ones are archived (cleans up existing pile-up).
  • flagged / rejected / archived → unchanged

author-design-md.ts: the "preserve status on re-run" rule is now gated on isRerun && !autoPublish. Editor re-runs (always autoPublish=false) keep preserving curated status exactly as before; bulk-upload re-runs (autoPublish=true) of a personal draft re-evaluate promotion like a fresh generation — otherwise a refreshed draft would stay personal forever and never publish.

Why this approach

It satisfies both requirements at once: URLs aren't permanently blocked (you still get a regeneration) and no duplicate draft rows accumulate. It reuses machinery already wired through both workers (targetBundleId + isRerun), so the change is to which job rows get created, not to pipeline behavior — low risk. The simpler "just add personal to the skip list" alternative would re-introduce the original "bad draft blocks the URL forever" bug.

Verification

  • pnpm typecheck — clean (0 errors in src/)
  • pnpm eslint on both changed files — clean

Not yet runtime-verified end to end; left as a draft for review before the merge triggers a production deploy.

Note on workflow

AGENTS.md prescribes committing directly to main for this solo project. This branch has diverged from origin/main (it's missing commits that are on main), so a clean fast-forward isn't possible and force-pushing main would clobber those commits. A PR is the safe path here — merging it does the proper merge and triggers the usual production deploy. If you'd rather I rebase onto current main and push there directly per the usual flow, say the word.

https://claude.ai/code/session_01DrHoAz6ZpPWURR9m4eNU6s


Generated by Claude Code

… duplicating

When a submitted URL already had a 'personal' draft bundle, bulk-upload
treated it as re-generatable and INSERTed a second bundle row, piling up
duplicate drafts on every run. Published/pending_review URLs were skipped,
but personal drafts were not.

Now a personal draft is re-run in place: the job is enqueued with
targetBundleId set so the pipeline UPDATEs the existing draft. If several
stale drafts exist for one normalized URL, the newest is targeted and the
older ones are archived. Published/pending_review still skip; flagged/
rejected/archived keep prior behavior.

author-design-md: gate the 'preserve status on re-run' rule on
isRerun && !autoPublish. Editor re-runs (always autoPublish=false) keep
preserving curated status; bulk-upload re-runs (autoPublish=true) of a
personal draft re-evaluate promotion like a fresh generation, so a
refreshed draft can publish instead of staying personal forever.

https://claude.ai/code/session_01DrHoAz6ZpPWURR9m4eNU6s
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-md Ready Ready Preview, Comment May 29, 2026 8:48pm

Request Review

Copy link
Copy Markdown
Owner Author

Closing — this change was pushed directly to main (commit 8b51ecf) per the repo's standing workflow (commit to main, auto-deploys to production). No separate merge needed.


Generated by Claude Code

@rayopavri rayopavri closed this May 29, 2026
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.

2 participants