Skip to content

Never reuse a tag number - #550

Merged
bernardnormier merged 2 commits into
icerpc:mainfrom
bernardnormier:never-reuse-tag-numbers
Sep 15, 2026
Merged

bernardnormier merged 2 commits into
icerpc:mainfrom
bernardnormier:never-reuse-tag-numbers

Conversation

@bernardnormier

Copy link
Copy Markdown
Member

The Tag semantics section of the Fields page said the only constraint on tagged fields is to never change the type associated with a tag number. That's incomplete: reusing a tag number with the same type keeps on-the-wire compatibility but breaks the application contract, since applications with the old definition decode the new field as the old one.

The rule is now "never reuse a tag number", with both consequences spelled out.

Fixes #213

🤖 Generated with Claude Code

The tag semantics section of the Fields page said the only constraint on tagged fields is to never change the type
associated with a tag number. That's incomplete: reusing a tag number with the same type keeps on-the-wire
compatibility but breaks the application contract, since applications with the old definition decode the new field as
the old one.

Fixes icerpc#213

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@InsertCreativityHere InsertCreativityHere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change some of the wording here, but (after going back and forth), I think it is good to mention this fact.

Even though I do find it a little strong at times (since you totally can do this, as long as you know any consumers of the old API are completely gone). But I think that's fine at a documentation level.

Comment thread content/slice/language-guide/fields.md Outdated
Comment on lines +110 to +111
never reuse a tag number: once you define `tag(7) name: string?` in a given tag number scope, tag 7 belongs to this
field forever, even after you remove the field. Reusing tag 7 with another type breaks on-the-wire compatibility with

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more clear, since it states a clear action users should take, and since I don't know what a tag "belonging to a field" means in-of-itself.

Suggested change
never reuse a tag number: once you define `tag(7) name: string?` in a given tag number scope, tag 7 belongs to this
field forever, even after you remove the field. Reusing tag 7 with another type breaks on-the-wire compatibility with
never reuse a tag number: once you define `tag(7) name: string?` in a given tag number scope, tag 7 should be reserved
forever, even after you remove the field. Reusing tag 7 with another type breaks on-the-wire compatibility with

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, "reserved" is clearer. I used "tag 7 stays reserved forever" rather than "should be reserved", since the sentence opens with "you must never".

Comment thread content/slice/language-guide/fields.md Outdated
You can add, remove and reorder tagged fields over time while maintaining on-the-wire compatibility. However, you must
never reuse a tag number: once you define `tag(7) name: string?` in a given tag number scope, tag 7 belongs to this
field forever, even after you remove the field. Reusing tag 7 with another type breaks on-the-wire compatibility with
applications that expect tag 7 fields to be encoded as strings. Reusing tag 7 with a string but a different meaning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rewrite this a little bit:

  • on-the-face of it, it sounds like you could have multiple fields all using the same tag.
    fields != arguments, so there should only be one field associated with tag(7) in a given context.
  • it's shorter without losing clarity IMO
  • earlier in this same sentence we say "Reusing tag 7 with another type"; no mention of the field.
Suggested change
applications that expect tag 7 fields to be encoded as strings. Reusing tag 7 with a string but a different meaning
applications that expect tag 7 to be of type `string`. Reusing tag 7 with a string but a different meaning

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, applied as suggested.

Comment thread content/slice/language-guide/fields.md Outdated
Comment on lines +113 to +114
preserves on-the-wire compatibility but breaks the application contract: applications that use the old definition
decode the new field as `name`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't actual explain what the problem is. It just states the fact that it will decode the new field as name, but, no issue is actually presented. Better to clearly state the issue:

Suggested change
preserves on-the-wire compatibility but breaks the application contract: applications that use the old definition
decode the new field as `name`.
preserves on-the-wire compatibility but breaks the application contract: applications that use the old definition
will still treat the decoded value as `name` instead of its new meaning.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. I went with "applications that use the old definition mistake the new field for name", which names the problem in fewer words.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@InsertCreativityHere InsertCreativityHere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

@bernardnormier
bernardnormier merged commit 4e0b6d6 into icerpc:main Sep 15, 2026
9 checks passed
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.

Adjust wording of "The only constraint is you can never change the type associated with a tag number"

3 participants