Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ingyamilmolinar opened this issue Jun 2, 2023 · 1 comment
Open

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

ingyamilmolinar opened this issue Jun 2, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ingyamilmolinar
Copy link

ingyamilmolinar commented Jun 2, 2023

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

@ingyamilmolinar ingyamilmolinar added the bug Something isn't working label Jun 2, 2023
@ingyamilmolinar
Copy link
Author

Might be related to this issue: jackc/pgx#1051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants