Repository navigation
Phase 6: Fix duplicate-enrichment dispatch + git-push race (#755) - #763
Merged
neuromechanist merged 2 commits intoJun 16, 2026
Conversation
Two concurrent enrichments (push-webhook run-enrichment.yml + in-process admin-reindex/import enrichDataset) both PUT .nemar/metadata.json to the same ref; the loser failed. The workflow client-push already rebase-retries, but the server-side createOrUpdateFile (Contents API) threw on the 409 stale-SHA with no retry. Wrap its GET-sha->PUT in a 3-attempt refetch loop, gated by a new pure isContentsApiShaConflict(status, body) (409, or 422 with a sha/does-not-match/ fast-forward message; mirrors isFastForwardConflict422). Last-writer-wins, no non-fast-forward failure; also closes the D1-ahead-of-repo divergence. No-mock detector test.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR763Version: 🤖 Updated on each push. |
(1) Narrow the 422 conflict regex: drop the bare 'sha' alternation (it over-matched unrelated 422s like 'Invalid sha for author' -> spurious retries); the 409 arm already covers the stale-blob conflict, and the real 422 phrases are 'does not match'/'not a fast forward'. (2) Add the unreachable-guard throw after the retry loop, matching commitFilesAsTree, so a future refactor can't silently return void. +tests for the no-over-match cases.
neuromechanist
merged commit Jun 16, 2026
ab44237
into
feature/issue-749-epic-import-robustness
1 check passed
This branch was previously deployed
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
Metadata enrichment raced itself: a push to README/dataset_description fires
/webhooks/github→ dispatchesrun-enrichment.yml(client-commits), while the import-finalize / admin-reindex path runsenrichDatasetin-process (force=true) and commits server-side. Both PUT.nemar/metadata.jsonto the same ref ~2s apart; the loser failed ("D1 cache is ahead of the repo").Root cause split:
git pushalready rebase-retries (run-enrichment.yml) → safe.createOrUpdateFile(Contents API) threw on the 409 stale-SHA with no retry — the actual failing path.run-enrichment.ymlhad no concurrency group, so N dispatches ran in parallel.This PR (backend half):
createOrUpdateFile's GET-sha → PUT in a 3-attempt refetch-retry, gated by a new pureisContentsApiShaConflict(status, body)(409, or 422 with a sha/"does not match"/"fast forward" message — mirrors the existingisFastForwardConflict422+commitFilesAsTree422 loop). Last-writer-wins, no failure; closes the D1-ahead-of-repo divergence. Benefits everycreateOrUpdateFilecaller.The
source_hashguard already no-ops sequential duplicates;.nemar/metadata.jsonis already excluded fromENRICHMENT_TRIGGER_PATHS(#643). Cross-repo concurrency group: nemarDatasets/.github#.Closes #755
Part of epic #749
Test plan
bun test(293 pass; new no-mockisContentsApiShaConflictcases — 409 always, 422-by-message, unrelated-422 not retried, non-conflict statuses never retried);tsc+biomeclean.