Repository navigation
Fix manage API gaps found migrating LexBox - #32
Merged
Merged
Conversation
Mercurial trusts a repo's hgrc (hooks, extensions) on the server, and an uploaded reset zip can carry one. LexBox's HgService already strips it; the manage API port didn't, so LexBox moving onto /api/manage would lose that protection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
3 tasks done
GET /api/manage/repos/{code}/backup zipped synchronously into the response
body, which Kestrel rejects, and the exception handler turned the resulting
InvalidOperationException into a 409. Write the zip with
CreateFromDirectoryAsync and allow synchronous IO on that one response,
since .NET still flushes each entry's DeflateStream synchronously on dispose.
Stop mapping every InvalidOperationException to 409: CopyRepo's "destination
not empty" now throws AlreadyExistsException, so other bugs surface as 500s.
Tests: backup through WebApplicationFactory (TestServer rejects sync IO like
Kestrel) and a backup/restore round trip against the container.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hahn-kev
added a commit
to sillsdev/languageforge-lexbox
that referenced
this pull request
Oct 28, 2026
sillsdev/hgresume#32 fixes the manage API backup endpoint (sync zip write failing under Kestrel) and strips uploaded hgrc files. Swap to the dated tag once it merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hahn-kev
added a commit
to sillsdev/languageforge-lexbox
that referenced
this pull request
Oct 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hahn-kev
added a commit
to sillsdev/languageforge-lexbox
that referenced
this pull request
Nov 5, 2026
* Move HgService repo filesystem ops onto hgresume's manage API The lexbox-api pod no longer mounts the hg repos volume. Init, copy, delete, backup, reset, finish-reset, soft-delete, cleanup, dir-cache invalidation and the abandoned-transaction check now call hgresume's /api/manage with the shared X-Manage-Secret. The repo-root chown init container moves to the hg pod, ahead of populate-test-repos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Temporarily run hgresume pr-32 image sillsdev/hgresume#32 fixes the manage API backup endpoint (sync zip write failing under Kestrel) and strips uploaded hgrc files. Swap to the dated tag once it merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Pin hgresume v2026-10-28 (includes sillsdev/hgresume#32) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Address CodeRabbit review on the manage API migration - BackupRepo disposes the headers-only response on any error status, not just 404, so a 401/500 from hgresume doesn't hold a connection open. - Drop HgConfig.ResetCleanupAgeDays: nothing reads it since cleanup moved to hgresume, which owns HGRESUME_RESET_CLEANUP_AGE_DAYS. - Bound the post-forward HasAbandonedTransactions check to 5s, since it runs while the send/receive ticket is still held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drop the abandoned-transaction check from the hg proxy It now costs an HTTP call to hgresume on every proxied send/receive request while the project's ticket is held, only to add a telemetry tag. The hasAbandonedTransactions GraphQL field still reports it on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Kevin Hahn <kevin_hahn@sil.org> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
AI summary
Two bugs in
/api/manage, both found while moving LexBox'sHgServiceonto it (sillsdev/languageforge-lexbox#2821).Uploaded
.hg/hgrcsurvivedFinishReset. Mercurial trusts a repo-level hgrc (hooks, extensions), so a user-uploaded one shouldn't land on the server. LexBox already stripped it; the port in #24 didn't.FinishResetnow deletes it.GET /repos/{code}/backupfailed under Kestrel with a 409. It zipped withZipFile.CreateFromDirectorystraight into the response body. Kestrel rejects synchronous writes, andApiExceptionHandlerturned the resultingInvalidOperationExceptioninto a "Conflict". The unit tests wrote into aMemoryStream, so they never saw it.ZipFile.CreateFromDirectoryAsync. .NET still flushes each entry'sDeflateStreamsynchronously on dispose, so the endpoint also setsAllowSynchronousIOfor that one response. The bulk of the zip is still written asynchronously.InvalidOperationExceptionno longer maps to 409.CopyRepo's "destination not empty" throwsAlreadyExistsException, which still does, so other bugs surface as 500s instead of a misleading 409.Image: LexBox needs an image with this before #2821 merges. Once this merges to master the workflow publishes
v<merge date>; until then there'spr-32.Test plan
FinishResetDropsUploadedHgrctheory (.hgat zip root and nested)ManageEndpointTestsruns backup throughWebApplicationFactory, whose TestServer rejects sync IO like Kestrel. It failed with the CI error before the fix and passes after.HgResume.Api.Tests19/19 locallyManageFacts.Backup_RestoresTheSameRepo(backup → finish-reset round trip against the container) in CI; Docker wasn't available locally🤖 Generated with Claude Code