node-auth0 icon indicating copy to clipboard operation
node-auth0 copied to clipboard

Every property is optional ConnectionForList, even id and name

Open Zertz opened this issue 8 months ago • 3 comments

Checklist

  • [x] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • [x] I have looked into the API documentation and have not found a suitable solution or answer.
  • [x] I have searched the issues and have not found a suitable solution or answer.
  • [x] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [x] I agree to the terms within the Auth0 Code of Conduct.

Description

#1093 changed the type from Connection to ConnectionForList but in the process made every property optional, which seems like a rather odd choice considering at least id and name are mandatory.

As asked by @cwkfs, why was this change made?

Reproduction

  1. Upgrade to v4.22.0

Additional context

No response

node-auth0 version

4.22.0

Node.js version

20

Zertz avatar Apr 23 '25 14:04 Zertz

Hi @Zertz

Thank you for bringing this up, and for the detailed context!

You're absolutely right — making all properties optional in ConnectionForList was not the intended behavior, especially since fields like id and name should remain required.

We’ll prioritize correcting the type definition. We'll keep this thread updated as we work on a fix.

Thank you

tanya732 avatar Jun 26 '25 06:06 tanya732

Hey @tanya732, I've noticed this issue remains with auth0@5 and has even spread to other types.

For example, every property in OrganizationConnection has become optional, which wasn't the case before. To be fair, the previous type may have wrong, however id cannot realistically be optional.

I understand the types are autogenerated and the actual issue may lie elsewhere but the fact remains that these types force us to add code that really shouldn't have to exist:

const organization = await managementClient.organizations.get("an-organization-id");

organization.id; // string | undefined

if (!organizationById.id) {
  throw new Error("This cannot happen but auth0 types are weird");
}

organization.id; // string

Zertz avatar Sep 17 '25 15:09 Zertz

Yes, I am seeing the same thing with UserReponseSchema and GetUserResponseContent too where all properties are optional (ID, name, email, etc). These types are returned by list and get functions on users.

jasonhilldm avatar Sep 27 '25 09:09 jasonhilldm