Skip to content

Comments

ContainerizationOCI: raise Reference name limit to 255 to match OCI spec#541

Merged
dcantah merged 1 commit intoapple:mainfrom
cluster2600:fix/453-name-length-limit
Feb 20, 2026
Merged

ContainerizationOCI: raise Reference name limit to 255 to match OCI spec#541
dcantah merged 1 commit intoapple:mainfrom
cluster2600:fix/453-name-length-limit

Conversation

@cluster2600
Copy link
Contributor

What

Raise the constant from 127 to 255 in Reference.swift and update the derived referenceTotalLengthMax accordingly.

Why

Closes #453.

The OCI distribution spec states that the name component of an image reference (registry host + repository path) may be at most 255 bytes. The previous hard-coded limit of 127 characters incorrectly rejected valid references that used long registry hostnames or deep path hierarchies.

The old referenceTotalLengthMax = 255 was also inconsistent: with a 127-char name cap, a 255-char total reference would only allow a very short tag. The new value is derived explicitly as nameTotalLengthMax (255) + separator (1) + tagLengthMax (128) = 384.

How

  • nameTotalLengthMax: 127 → 255
  • tagLengthMax: new constant (128) documenting the maximum tag length already enforced by the tag regex ({0,127} + leading char = 128 chars).
  • referenceTotalLengthMax: computed from the two constants above (384) rather than hard-coded to 255.

Testing

Added three new cases in ReferenceTests.swift:

  • ✅ Name of 128 characters (registry + path) — previously rejected, now accepted
  • ✅ Name of exactly 255 characters — at the OCI spec maximum, accepted
  • ❌ Name of 256 characters — one over the limit, rejected

Checklist

  • I have read CONTRIBUTING.md
  • My changes follow the existing code style
  • I have added tests that cover the fix
  • All commits are GPG-signed

The OCI distribution spec allows repository names (domain + path) of up
to 255 bytes. The previous hard-coded limit of 127 characters incorrectly
rejected valid references that use long registry hostnames or deep path
hierarchies.

Changes:
- nameTotalLengthMax: 127 → 255 (OCI spec maximum for name component)
- referenceTotalLengthMax: now computed as nameTotalLengthMax (255) +
  separator (1) + tagLengthMax (128) = 384, accommodating a full
  reference with the maximum name and the maximum tag length.
- Added tests for names of 128 and 255 characters (both now valid) and
  for names of 256 characters (still rejected).

Closes apple#453
@jglogan jglogan requested a review from adityaramani February 19, 2026 15:52
@jglogan
Copy link
Contributor

jglogan commented Feb 19, 2026

@cluster2600 Thank you for the submission!

@adityaramani Assigned you to review when you have a moment. I pasted some code from an earlier implementation to issue #453 for comparison.

@jglogan jglogan modified the milestones: 2026-03, 2026-02 Feb 20, 2026
@dcantah dcantah merged commit 86171ac into apple:main Feb 20, 2026
3 checks passed
@cluster2600 cluster2600 deleted the fix/453-name-length-limit branch February 20, 2026 21:50
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.

[Request]: Allow repository length to be greater than 127 symbols

4 participants