Skip to content

Context Error Invoking SyncUser() #46

@gingersab

Description

@gingersab

I'm seeing an issue with SyncUser(ctx, *models.UserCreate). Regardless of how the context is created or passed, I hit the error ErrorCode: ContextError, ErrorType: general_error, Message: The context is missing or invalid

The following is based on the example provided in the README

Permit configuration is in its own package

type PermitService struct {
	permitCfg      *config.PermitConfig
	permitOperator *permit.Client
}

func NewPermitService(token string) *PermitService {
	cfg := config.NewConfigBuilder(token).Build()
	client := permit.New(cfg)
	return &PermitService{
		permitCfg:      &cfg,
		permitOperator: client,
	}
}

func (permitSvc *PermitService) AddUser(username string, ctx context.Context) {
	newUser := models.NewUserCreate(username) //works
	_, err := permitSvc.permitOperator.SyncUser(ctx, *newUser) //produces context error
	if err != nil {
		log.Fatal(err.Error())
	}
}

Attempt to add a new user originates from a different package

ctx := context.TODO() //also tried background context
permitSvc := pdp.NewPermitService(pdpApiKey) //pdpApiKey is valid
pdpSvc := pdp.NewPdpService(permitSvc) //abstraction layer
pdpSvc.PdpSvc.AddUser("test-user", ctx)

From what I've been able to ascertain, the error originates from the call to

client.APIKeysApi.GetApiKeyScope(ctx).Execute()

and is returned here

return nil, PermitErrors.NewPermitContextError(additionalErrorMessage)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions