Typescript - client updateUser should throw typescript error on attempting to update an additionalFields marked as input: false #305

Closed
opened 2026-03-13 07:41:20 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @arfath-linklet on GitHub (Dec 1, 2024).

Describe the bug
Consider a config with additionalField:

user: {
    additionalFields: {
      role: {
        type: "string",
        required: false,
        input: false, // don't allow user to set role
      }
    },
  }

on the client attempt to updateUser

client.updateUser({ role: 'admin' })

No typescript error is thrown. Server correctly ignores the field but should it throw a validation error? Server to have strict input checking on all APIs?

Expected behavior
updateUser should accept only client updates with input: true. Additionally API could throw validation errors as additional safety check.

Originally created by @arfath-linklet on GitHub (Dec 1, 2024). **Describe the bug** Consider a config with additionalField: ``` user: { additionalFields: { role: { type: "string", required: false, input: false, // don't allow user to set role } }, } ``` on the client attempt to updateUser ``` client.updateUser({ role: 'admin' }) ``` No typescript error is thrown. Server correctly ignores the field but should it throw a validation error? Server to have strict input checking on all APIs? **Expected behavior** `updateUser` should accept only client updates with input: true. Additionally API could throw validation errors as additional safety check.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#305