Skip to content

Reserve id 0 in NameIDMapper for proto3 unset#93

Merged
xytan0056 merged 1 commit into
mainfrom
tanx/reserve-id-zero-proto3
May 29, 2026
Merged

Reserve id 0 in NameIDMapper for proto3 unset#93
xytan0056 merged 1 commit into
mainfrom
tanx/reserve-id-zero-proto3

Conversation

@xytan0056
Copy link
Copy Markdown
Contributor

NameIDMapper handed out 0 as a legitimate id, colliding with proto3 semantics where 0 is the default/unset value for int32. Consumers using encoding/json (which honors omitempty) silently dropped any target, rule type, tag, or attribute whose id happened to be 0, making the entry invisible by name in the response.

that's why we have
image
where there's no ID. So our CLI call missed the target. It only happens to the first target entering NewNameIDMapper.

Start ids at 1 in both NameIDMapper and the topologically-ordered targetNamesMapping in ResultToGetTargetGraphResponse, keeping 0 reserved. Add a regression test asserting 0 is never assigned.

Test Plan

unit test

Issue

NameIDMapper handed out 0 as a legitimate id, colliding with proto3
semantics where 0 is the default/unset value for int32. Consumers using
encoding/json (which honors omitempty) silently dropped any target,
rule type, tag, or attribute whose id happened to be 0, making the
entry invisible by name in the response.

Start ids at 1 in both NameIDMapper and the topologically-ordered
targetNamesMapping in ResultToGetTargetGraphResponse, keeping 0 reserved.
Add a regression test asserting 0 is never assigned.
@xytan0056 xytan0056 requested review from a team as code owners May 29, 2026 15:49
@xytan0056 xytan0056 merged commit ed8c044 into main May 29, 2026
6 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.

2 participants