Skip to content

processUrlPath rejects smart-HTTP requests when the repo path omits .git #1588

@cniska-oura

Description

@cniska-oura

Describe the bug

processUrlPath only accepts request paths that contain .git before the smart-HTTP suffix (regex (.+\.git)(\/.*)?/). Many clients send paths without .git, e.g. /owner/repo/info/refs?service=git-upload-pack. Those requests fail parsing before the plugin chain runs. GitHub accepts both forms.

To Reproduce

Steps to reproduce the behavior:

  1. Run @finos/git-proxy@2.0.0 with a repository on the authorised list.
  2. Send a smart-HTTP discovery request without .git in the path: GET /owner/repo/info/refs?service=git-upload-pack
  3. Send the same request with .git: GET /owner/repo.git/info/refs?service=git-upload-pack
  4. See error on step 2: smart-HTTP pkt-line Invalid request received (HTTP 200); git clone fails (could not determine hash algorithm; is this a git repository?). Step 3 succeeds.

Expected behavior

Both path forms parse and reach the normal action/plugin chain. Normalising .git-less paths to a repoPath ending in .git internally is fine.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: Linux; macOS
  • Browser: N/A (HTTP client / git CLI)
  • Version: Node 20+; @finos/git-proxy 2.0.0

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context

Suggested change inside processUrlPath (after the existing .git match fails):

const SMART_HTTP = /^(.+?)(\/(?:info\/refs|git-upload-pack|git-receive-pack)(?:\?.*)?)$/;

const smartHttp = requestPath.match(SMART_HTTP);
if (smartHttp) {
  return { repoPath: smartHttp[1] + '.git', gitPath: smartHttp[2] };
}

Happy to open a PR if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions