镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Bug] reject non-canonical git change IDs #796

Description

@DivyanshGarg380

Description

ParseChangeID accepts Git change IDs that are not in their canonical form.

The parser uses net/url, which can normalize parts of the URI or drop them entirely. As a result, different input strings can be parsed into the same ChangeID.

For example, inputs with an uppercase scheme, userinfo, query parameters, fragments, or non-canonical percent-encoding are currently accepted even though they don't round-trip to the original string.

The parser also accepts empty segments in the repository path.

Steps to Reproduce

  1. Call ParseChangeID with a non-canonical Git change ID, for example:
    GIT://git.example.com/uber/monorepo/refs%2Fheads%2Fmain/<sha>
  2. Observe that parsing succeeds.
  3. Call String() on the returned ChangeID.
  4. The resulting string is different from the original input.

The same issue can be reproduced with userinfo, query parameters, fragments, lowercase percent-encoding, unnecessary percent-encoding, and empty repository path segments.

Expected Behavior

ParseChangeID should reject any input that is not in canonical form.

A valid change ID should round-trip exactly:

ParseChangeID(raw).String() == raw

Actual Behavior

Non-canonical inputs are accepted and net/url normalizes or drops parts of them during parsing.

For example, an uppercase GIT:// scheme is parsed as git://, and query parameters or fragments are not included in the resulting ChangeID.

Environment

  • Go version: go1.27.1
  • OS: Windows
  • Bazel version: 8.4.1

Logs / Screenshots

Not applicable.

Additional Context

This can result in multiple different strings representing the same change ID.

The parser should enforce a single canonical representation so that change IDs are unambiguous.

Activity

  1. changed the title [-][Bug][/-] [+][Bug] reject non-canonical git change IDs[/+] on Oct 7, 2026
  2. added a commit that references this issue on Oct 8, 2026
    561518b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions