Skip to content

[BUG] permify cannot handle Uint64 for uint IDs #6

@ingyamilmolinar

Description

@ingyamilmolinar

Describe the bug
When I try to use a uint taken from a unit64 as a user ID in UserHasAnyRoles(id, "admin"), I get the following error:

/go/pkg/mod/github.com/!permify/permify-gorm@v1.0.0/repositories/userRepository.go:199 failed to encode args[0]: unable to encode 0xe40e81495b2643ba into binary format for int8 (OID 20): 16433214242383348666 is greater than maximum value for int64
[0.643ms] [rows:0] SELECT count(*) FROM "user_roles" WHERE user_roles.user_id = 16433214242383348666 AND user_roles.role_id IN (1)

Versions

Permify-gorm version: 1.0.0

Go version: 1.20

Gorm version: v1.25.0

Database driver name: gorm.io/driver/postgres v1.5.2

Database version: 15.3

To Reproduce
Steps to reproduce the behavior:

import (
	"github.com/google/uuid"
	"encoding/binary"
	permify "github.com/Permify/permify-gorm"
)

func UintFromUUID(id uuid.UUID) uint {
	return uint(binary.BigEndian.Uint64(id[:8]))
}
_, err := permify.UserHasAnyRoles(UintFromUUID(claim.ID), "admin")
// err != nil

Expected behavior
UserHasAnyRoles should work since the PG DB column is BIGINT which is 64 bits in size and my code produces a uint based on a 64bit integer.

Additional context
Add any other context about the problem here.

Environment (please complete the following information, because it helps us investigate better):
I'm using golang:1.20.3-alpine3.17 Docker image

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions