Repository navigation
fix: report what a repository sync actually did - #1922
Merged
Merged
Conversation
Four ways the instrument repository pages disagreed with the sync behind them. An import that discovered no instrument directories was recorded as a success with 0 imported. A repository laid out any other way downloads cleanly and yields nothing, so that entry was indistinguishable from a genuinely empty repository, against the rule that nothing fails silently. `importInstruments` now refuses it, naming the four `lib/*` directories it looked in and what it looked for, so the entry reads FAILED with an actionable reason and adding such a repository fails up front rather than registering it with nothing in it. A sync no longer replaces the stored instrument list unless it matched something. Every instrument failing to load — a bad upstream commit, a series whose member edition is gone — is not evidence that the repository provides nothing, and writing an empty list would de-list instruments that are still stored and still assignable. The entry records each failure, so such a pass is reported rather than hidden. The repositories page counted and listed instruments by `sourceRepoId`, which records which import created an instrument, while the activity log counted `instrumentIds`, which is what the repository provides. The two differ for every instrument already stored when the repository was registered: the import recovers its id from the conflict and counts it, but leaves its provenance alone. A repository could report 22 imported and list 12. Both the count and the dialog now resolve the ids the repository provides through one function, so neither can drift from the other, and an id whose instrument was since deleted is in neither. The activity log recorded only the total, so an import of instruments already present read as 22 new. A sync now also records how many it created, and the Imported cell reads `22 (12 new)` with the whole split on hover. The field is nullable because Mongo has no migration: an entry written before this has no count, which is not zero. An entry that imported nothing reads as the bare total, since a run that stored nothing has no split to show. The status itself consulted neither count: a repository-level message read as a failure and any instrument failure as a partial success. A readable repository whose every instrument fails to compile or load records no message and nothing imported, so the log announced "Partial success" beside an imported count of 0. A partial success needs a part that succeeded, so such an entry now reads FAILED, while one that stored some of its instruments and skipped others still reads PARTIAL. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
This pull request was closed because its body does not meet
Fix the body with |
|
This pull request was closed because its body does not meet
Fix the body with |
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.
An administrator adding or syncing an instrument repository is now told what the sync did. A repository laid out in any way other than
lib/{file,forms,interactive,series}used to register cleanly and import nothing, logged as a success with 0 imported, and the repositories page could report 22 imported while listing 12 of them. This was found on a live instance whose 22 forms sat underpublic/forms, where every page agreed that nothing was wrong.Changes
lib/*directories looked in and the index filenames looked for, instead of registering a repository with nothing in it.22 (12 new)with22 imported: 12 new, 10 already storedon hover. An entry that imported nothing, and one written before the field existed, read as the bare total.InstrumentRepoSyncLoggains a nullablecreatedCount, andcreatedCountbecomes an acceptedsortByvalue forGET /v1/instrument-repos/sync/logs.Decisions
createdCountis nullable rather than defaulted to 0. MongoDB has no migration here, so an entry written before this field has no count, which is not the same fact as having created nothing; the UI renders the two identically but the column keeps the distinction.admin-instrument-repos.spec.tsholds both tables to the 764px the admin page has. Real columns need something else dropped or a wider table.instrumentIds.lengthdirectly, which costs a correct count on first paint: it shows the id count until the instruments load, then refines. The alternative kept the fast path but let the column claim an instrument the dialog could not show.BadGatewayException.downloadAndExtractRepoalready reports a wrong URL, a missing repository and an insufficient token the same way;BadRequestExceptionin this module is reserved for a URL that fails to parse, before any upstream call.Risks
sourceRepoId: null, so the group-manage visibility rule treats it as manually uploaded. This change does not touch that; it is unchanged from before and stays as it was.InstrumentsService.deleteByIddoes not prune the deleted id from any repository'sinstrumentIds, so a stale id survives until the next successful sync. The count and the dialog now both leave such an id out, so the page is consistent, but the stored list stays wrong until then. Accepted: pruning on delete is the structural fix and belongs with that method, not here.Notes
Verified against a live instance with two real repositories (26 and 27 instruments): the column matches the activity log's total, the hover split matches a sync that re-found 26 instruments and created 5 of them, and an entry written before
createdCountexisted still renders. Sync-log rows covering each rendering — refused import, all instruments failed, partial, re-found, unreadable repository — were inserted directly and inspected.Adversarial review
Reviewed at commit 8adf22b. pnpm check: green.
Findings
apps/api/src/instrument-repos/instrument-repos.service.ts:633(withapps/web/src/routes/_app/admin/instrument-repos/index.tsx:232) — a sync in which every instrument fails to load still replacesinstrumentIdswith[], and now that the web page reads both the count and the View dialog off that list, such a sync makes a repository report zero instruments it in fact still provides — guard the case where nothing was matched, or keep the previously stored ids, so a failed pass never de-lists instruments the repository still provides.apps/web/src/routes/_app/admin/instrument-repos/index.tsx:232— the repositories table's instrument count and the View dialog's instrument list are now derived from two different sources, so they disagree whenever an id ininstrumentIdshas no stored instrument — derive the count from the same function as the list once the instrument info has loaded, or prune the id on delete.Fixed
syncReporeplaces the stored instrument list only when the pass matched something, leavinglastSyncedAtuntouched too, with the failures still recorded against the entry.providedInstruments, the same function the dialog lists, withinstrumentIds.lengthonly as the pre-query fallback.Attestation
I, Claude Opus 5, attest that the review block above reports the adversarial review as it ran on the commit named, with every finding it returned.