fix: deduplicate BCOS directory project loads#5732
Open
ItsOtherMauridian wants to merge 1 commit into
Open
Conversation
TJCurnutte
approved these changes
May 19, 2026
TJCurnutte
left a comment
There was a problem hiding this comment.
Approved — this fixes the duplicate BCOS directory load path rather than only adding test coverage.
Validation I ran against head 04d278c9574c50b66eba607d7a66ce5f4a3b714c:
git diff --check origin/main...HEAD -- bcos_directory.py tests/test_bcos_directory_security.pypython3 -B -m py_compile bcos_directory.py tests/test_bcos_directory_security.pyPYTHONPATH=. python3 -B -m pytest -q tests/test_bcos_directory_security.py --tb=short -p no:cacheprovider→6 passed in 0.05s- Direct SQLite origin-main-vs-PR probe:
origin/mainloaded the samedata/projects.jsontwice into 2 rows forScottcjn/Rustchainand had no unique index; this PR loaded it into 1 row and created uniqueidx_projects_github_repo. - Pre-existing duplicate cleanup probe:
origin/mainleft botholdandnewrows; this PR kept the latest row (latest_sha='new') and then created the unique index without error.
Reasoning: the previous INSERT OR REPLACE had no conflict target because only the autoincrement id was unique, so repeated JSON loads appended duplicate project rows. Adding a unique index on github_repo, after a one-time cleanup of already-duplicated rows, gives the loader a real conflict target and keeps the migration safe for existing DBs. I do not see a blocker in the changed path.
jaxint
approved these changes
May 19, 2026
Contributor
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
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
Fixes #5731.
load_projects_from_json()usedINSERT OR REPLACE, but theprojectstable only had an autoincrementidprimary key. Re-running the JSON loader for the samegithub_repotherefore appended duplicate BCOS directory rows instead of replacing/updating the existing project entry.This PR:
projectsrows bygithub_repoduringinit_db()before adding the constraint;projects(github_repo)so futureINSERT OR REPLACEcalls have a real conflict target;Validation
Note: local environment needed Flask supplied via a temporary dependency target because the base runner here does not have Flask installed globally.