Skip to content

[BUG] Hostname rule rejects a 253-character name with a trailing dot, which the docs say is valid #512

Description

@LordAizen1

Description

The hostname rule in proto/protovalidate/buf/validate/validate.proto documents:

  • The name can be 253 characters at most, excluding the optional trailing dot.

So a 253-character name with a trailing dot (254 bytes total) should be valid. But all four runtimes check the full length before stripping the trailing dot, so the dot is counted against the limit and the name is rejected. Same ordering in each:

runtime location
protovalidate-go internal/rules/rules.go IsHostname
protovalidate-python protovalidate/_funcs.py:213 _is_hostname
protovalidate-java CustomOverload.java:546 isHostname
protovalidate-cc internal/extra_func.cc:174 IsHostname

They agree with each other but all disagree with the docs, so it looks like one spec-vs-implementation gap rather than runtime drift.

Steps to Reproduce

With a name of exactly 253 valid chars (63 + 1 + 63 + 1 + 63 + 1 + 61), calling the real IsHostname/_is_hostname on main:

len=253  hostname=true    253-char name
len=254  hostname=false   253-char name + trailing dot   <-- docs say valid
len=254  hostname=false   254-char name

Reproduced against main in the real Go and Python code (not a transcription); Java and C++ confirmed by reading the source at the lines above.

Expected Behavior

The 253-character name with a trailing dot is accepted.

Actual Behavior

It is rejected, because the length check counts the trailing dot.

Environment

  • Version: main (protovalidate-go f360e52, protovalidate-python 0027695)
  • Toolchain: Go 1.26.4, CPython 3.12

Possible Solution

Strip the trailing dot before the length check. Since this is the conformance repo, a conformance case (253 chars + dot, expected valid) would hold every runtime to the rule, but it would fail against all four until they're fixed, so I raised this as an issue first to let you pick the sequencing. If the 253 limit was meant to include the dot, it's a one-line docs fix instead and I'm happy to send that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions