Skip to content

Add int-type Authz ID proto fields alongside any string-type proto fields#8754

Open
ezekiel wants to merge 2 commits into
mainfrom
ezekiel/unify-authzid-type-stage1
Open

Add int-type Authz ID proto fields alongside any string-type proto fields#8754
ezekiel wants to merge 2 commits into
mainfrom
ezekiel/unify-authzid-type-stage1

Conversation

@ezekiel
Copy link
Copy Markdown
Member

@ezekiel ezekiel commented May 19, 2026

This is stage one of normalizing Authz ID to be consistently int64-type (#8722).

This is stage one of normalizing Authz ID to be consistently int64-type.
@ezekiel ezekiel requested a review from a team as a code owner May 19, 2026 15:22
@ezekiel ezekiel requested a review from jsha May 19, 2026 15:22
Comment thread va/caa.go

// TODO(#8722): remove this whole thing when Authz IDs are int64-only
var authzID int64
if len(strings.TrimSpace(req.AuthzID)) > 0 {
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.

Maybe this would be better to just collapse into:

if authzID, err := strconv.ParseInt() {

?

Comment thread core/objects.go
Comment on lines +272 to +273
ID string `json:"-"`
IDInt int64 `json:"-"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rather than carrying these side-by-side, the in-memory core.Authorization should only have an int field. We'll use pb-marshalling.go to ensure that the int is always appropriately populated.

Suggested change
ID string `json:"-"`
IDInt int64 `json:"-"`
ID int64 `json:"-"`

Comment thread grpc/pb-marshalling.go
Comment on lines 294 to +295
Id: authz.ID,
IdInt: authz.IDInt,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since core.Authorization now only has an int64 ID field, use that to populate both protobuf fields:

Suggested change
Id: authz.ID,
IdInt: authz.IDInt,
Id: fmt.Sprintf("%d", authz.ID),
IdInt: authz.ID,

Comment thread grpc/pb-marshalling.go
Comment on lines 320 to +321
ID: pb.Id,
IDInt: pb.IdInt,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one is harder, but what we want to do is:

  1. Try to populate ID from pb.IdInt;
  2. But if that's zero, instead try to parse pb.Id from a string to and int;
  3. But if that fails or is also zero, return an error.

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