Skip to content

Replace a request header with the batch action's value instead of adding a second one - #129

Open
hulucc wants to merge 1 commit into
ktsu-dev:mainfrom
hulucc:fix/action-header-replaces-request-default
Open

hulucc wants to merge 1 commit into
ktsu-dev:mainfrom
hulucc:fix/action-header-replaces-request-default

Conversation

@hulucc

@hulucc hulucc commented Oct 22, 2026

Copy link
Copy Markdown

Problem

Pushing an LFS object through the proxy to a Gitea upstream fails at the verify step. The object PUT succeeds, but the relayed POST .../info/lfs/verify gets 415 Unsupported Media Type, and git-lfs reports the push as failed.

Observed with Gitea 28.2.0 and git-lfs 3.8.0 behind ktsu.GitLfsCache 1.12.5. Pulls, locks and the rest of the batch flow work.

Cause

UpstreamRequests.BuildVerifyRequest sets Accept: application/vnd.git-lfs+json, then ApplyTokenHeaders adds every entry of the action's header map with TryAddWithoutValidation, which appends. Gitea includes Accept in every verify action (services/lfs/server.go), so upstream receives:

Accept: application/vnd.git-lfs+json, application/vnd.git-lfs+json

Gitea's CheckAcceptMediaType compares the whole header value against the media type and answers 415. Called directly against Gitea with everything else equal:

Accept Response
application/vnd.git-lfs+json 200
application/vnd.git-lfs+json, application/vnd.git-lfs+json 415

Gitea's comparison is stricter than it needs to be, but sending one header twice is the proxy's to fix regardless: the action's header map is what upstream asked to be sent with that action, so its value should take the place of the builder's default rather than become a second value.

Change

  • ApplyTokenHeaders removes the request's own value of a header before adding the action's, for request and content headers alike. NonValidated.Contains is used for the check because it never throws, so it also tells which collection may hold the name.
  • Two tests: an Accept and a Content-Type in a verify action's header map each reach upstream as a single value. Both fail without the change.

Verification

  • dotnet test on SDK 10.0.402: 415 passed, 0 failed.
  • Built into an image and deployed in front of Gitea 28.2.0: a 48 MB push through the proxy succeeds, the object round-trips with a matching sha256 when cloned straight from Gitea, and a later pull through the proxy is served from the store with no upstream fetch.

🤖 Generated with Claude Code

…ing a second one [patch]

ApplyTokenHeaders added each entry of an action's header map with
TryAddWithoutValidation, which appends. A header the request builder had
already set therefore went upstream with two values.

Gitea puts Accept in every verify action, so the verify relay sent
"Accept: application/vnd.git-lfs+json, application/vnd.git-lfs+json".
Gitea compares the whole Accept value and answers 415, and git-lfs then
fails every push through the proxy at the verify step, after the object
itself has already been uploaded.

- ApplyTokenHeaders removes the request's own value of a header before
  adding the action's, for request and content headers alike
- Tests: an Accept and a Content-Type in a verify action's header map
  each reach upstream as a single value

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant