Repository navigation
Fix manage API gaps found migrating LexBox: hgrc strip, backup under Kestrel - #32
Open
hahn-kev-bot wants to merge 2 commits into
Open
hahn-kev-bot wants to merge 2 commits into
hahn-kev-bot wants to merge 2 commits into
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>
Open
2 of 3 tasks
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>
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