Skip to content

Bug: Decoding of properties with null value fails #40

Description

@repolevedavaj

Prerequisites

Describe the issue

I am using this client in my Terraform provider and currently face an error when the Kinde API returns a JSON property with a null value.

E.g. if I create a permission without description, I am not able anymore to fetch it with this client as the decoding fails:

Create request code:

_, err := HandleResponse[SuccessResponse](r.client.CreatePermission(ctx, NewOptCreatePermissionReq(CreatePermissionReq{
	Name:        ToOptString(data.Name),
	Key:         ToOptString(data.Key),
	Description: ToOptString(data.Description),
})))

Example request body:
{"name":"CMI Show Dashboard","key":"cmi:show:dashboard"}

Read request code:

response, err := HandleResponse[GetPermissionsResponse](r.client.GetPermissions(ctx, GetPermissionsParams{
	Sort:      NewOptNilGetPermissionsSort(GetPermissionsSortIDDesc),
	PageSize:  NewOptNilInt(10),
	NextToken: currentToken,
}))

Example response body:

{
    "code": "OK",
    "message": "Success",
    "next_token": "MTo6OmlkX2Rlc2M=",
    "permissions": [
        {
            "id": "019a12ad-0dad-117d-a831-083bf2fdab86",
            "key": "cmi:show:dashboard",
            "name": "CMI Show Dashboard",
            "description": null
        }
    ]
}

Error while parsing:

decode response: decode application/json: decode GetPermissionsResponse: callback: decode field \"permissions\": callback: decode Permissions: callback: decode field \"description\": unexpected byte 110 'n' at 208"

Library URL

https://github.com/kinde-oss/kinde-go

Library version

0.1.8

Operating system(s)

Windows

Operating system version(s)

Windows 11

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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