Skip to content

web/forms: fix invalid date error for empty datetime-local inputs#19561

Merged
GirlBossRush merged 2 commits intomainfrom
sdko/fix-form-datetime
Jan 19, 2026
Merged

web/forms: fix invalid date error for empty datetime-local inputs#19561
GirlBossRush merged 2 commits intomainfrom
sdko/fix-form-datetime

Conversation

@dominic-r
Copy link
Member

Overview:

When a datetime-local input is empty, valueAsNumber returns NaN and new Date("") creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused "RangeError: Invalid time value" when toISOString() was called. Now empty datetime inputs correctly serialize to null.

Testing:

  1. Go to Directory > Tokens and App passwords
  2. Create or edit a token
  3. Uncheck the "Expiring" checkbox
  4. Save the token
  5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558

@dominic-r dominic-r added this to the Release 2025.12.2 milestone Jan 19, 2026
@dominic-r dominic-r self-assigned this Jan 19, 2026
@dominic-r dominic-r requested a review from a team as a code owner January 19, 2026 03:07
@dominic-r dominic-r added area:frontend Features or issues related to the browser, TypeScript, Node.js, etc backport/version-2025.12 Add this label to PRs to backport changes to version-2025.12 labels Jan 19, 2026
@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 61e106f
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/696da773ff35f6000826b938
😎 Deploy Preview https://deploy-preview-19561--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 810aedf
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/696d9ff3820e6a00085d6f22
😎 Deploy Preview https://deploy-preview-19561--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.28%. Comparing base (1837bec) to head (18fdb9c).
⚠️ Report is 167 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19561   +/-   ##
=======================================
  Coverage   93.28%   93.28%           
=======================================
  Files         949      949           
  Lines       52067    52067           
=======================================
  Hits        48572    48572           
  Misses       3495     3495           
Flag Coverage Δ
conformance 38.25% <ø> (+<0.01%) ⬆️
e2e 44.19% <ø> (+<0.01%) ⬆️
integration 23.20% <ø> (+<0.01%) ⬆️
unit 91.50% <ø> (+0.01%) ⬆️
unit-migrate 91.51% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-18fdb9cf9947c5dea3e7fca1c34ad30877da4953
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-18fdb9cf9947c5dea3e7fca1c34ad30877da4953

Afterwards, run the upgrade commands from the latest release notes.

Overview:

When a datetime-local input is empty, `valueAsNumber` returns `NaN` and `new Date("")` creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused  "RangeError: Invalid time value" when `toISOString()` was called. Now empty datetime inputs correctly serialize to `null`.

Testing:

1. Go to Directory > Tokens and App passwords
2. Create or edit a token
3. Uncheck the "Expiring" checkbox
4. Save the token
5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558
@dominic-r dominic-r force-pushed the sdko/fix-form-datetime branch from 61e106f to 18fdb9c Compare January 19, 2026 12:10
@github-project-automation github-project-automation bot moved this from Todo to In Progress in authentik Core Jan 19, 2026
@GirlBossRush GirlBossRush merged commit 0d2dcbf into main Jan 19, 2026
101 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in authentik Core Jan 19, 2026
@GirlBossRush GirlBossRush deleted the sdko/fix-form-datetime branch January 19, 2026 16:03
authentik-automation bot pushed a commit that referenced this pull request Jan 19, 2026
…9561)

* web/forms: fix invalid date error for empty datetime-local inputs

Overview:

When a datetime-local input is empty, `valueAsNumber` returns `NaN` and `new Date("")` creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused  "RangeError: Invalid time value" when `toISOString()` was called. Now empty datetime inputs correctly serialize to `null`.

Testing:

1. Go to Directory > Tokens and App passwords
2. Create or edit a token
3. Uncheck the "Expiring" checkbox
4. Save the token
5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558

* web: lint
@authentik-automation
Copy link
Contributor

🍒 Cherry-pick to version-2025.12 created: #19582

BeryJu pushed a commit that referenced this pull request Jan 20, 2026
…erry-pick #19561 to version-2025.12) (#19582)

web/forms: fix invalid date error for empty datetime-local inputs (#19561)

* web/forms: fix invalid date error for empty datetime-local inputs

Overview:

When a datetime-local input is empty, `valueAsNumber` returns `NaN` and `new Date("")` creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused  "RangeError: Invalid time value" when `toISOString()` was called. Now empty datetime inputs correctly serialize to `null`.

Testing:

1. Go to Directory > Tokens and App passwords
2. Create or edit a token
3. Uncheck the "Expiring" checkbox
4. Save the token
5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558

* web: lint

Co-authored-by: Dominic R <dominic@sdko.org>
@dominic-r dominic-r added the backport/version-2025.10 Add this label to PRs to backport changes to version-2025.10 label Jan 29, 2026
authentik-automation bot pushed a commit that referenced this pull request Jan 29, 2026
…9561)

* web/forms: fix invalid date error for empty datetime-local inputs

Overview:

When a datetime-local input is empty, `valueAsNumber` returns `NaN` and `new Date("")` creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused  "RangeError: Invalid time value" when `toISOString()` was called. Now empty datetime inputs correctly serialize to `null`.

Testing:

1. Go to Directory > Tokens and App passwords
2. Create or edit a token
3. Uncheck the "Expiring" checkbox
4. Save the token
5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558

* web: lint
@authentik-automation
Copy link
Contributor

🍒 Cherry-pick to version-2025.10 created: #19850

gergosimonyi added a commit that referenced this pull request Feb 2, 2026
We aim to fix
#19911 in the next patch
release, so this commit shouldn't include an API change, which is why we
do it a bit awkwardly. Additionally, `serializeForm` has no typechecking
for its return value (`return json as unknown as T`), and should be
refactored for type safety if at all possible.

There are at least two bugs we're solving in this commit:

1. Type checking fails on `serializeForm`, which results in
`expires: null` POSTed in a `UserServiceAccountRequest`, where it is not
allowed. The backend "correctly" returns a 400. For now we address this
by returning `undefined` from `serializeForm` on a `datetime-local`
input element when it is unset.

2. The schema allows for `expires: null` in `TokenModel`, but fails with
a 500 when that is actually sent. For now we address this with a `None`
check. (Note: this bug will not be encountered by the frontend after the
change from `null` to `undefined`, but it's still nice to fix.)

Both of these issues should eventually be solved by the backend handling
`ExpiringModel` in an `ExpiringModelSerializer` instead of the current
ad hoc way.

Introduced by #19561
dominic-r added a commit that referenced this pull request Feb 2, 2026
core: fix datetime (de)?serialization

We aim to fix
#19911 in the next patch
release, so this commit shouldn't include an API change, which is why we
do it a bit awkwardly. Additionally, `serializeForm` has no typechecking
for its return value (`return json as unknown as T`), and should be
refactored for type safety if at all possible.

There are at least two bugs we're solving in this commit:

1. Type checking fails on `serializeForm`, which results in
`expires: null` POSTed in a `UserServiceAccountRequest`, where it is not
allowed. The backend "correctly" returns a 400. For now we address this
by returning `undefined` from `serializeForm` on a `datetime-local`
input element when it is unset.

2. The schema allows for `expires: null` in `TokenModel`, but fails with
a 500 when that is actually sent. For now we address this with a `None`
check. (Note: this bug will not be encountered by the frontend after the
change from `null` to `undefined`, but it's still nice to fix.)

Both of these issues should eventually be solved by the backend handling
`ExpiringModel` in an `ExpiringModelSerializer` instead of the current
ad hoc way.

Introduced by #19561

Co-authored-by: Simonyi Gergő <gergo@goauthentik.io>
authentik-automation bot pushed a commit that referenced this pull request Feb 2, 2026
core: fix datetime (de)?serialization

We aim to fix
#19911 in the next patch
release, so this commit shouldn't include an API change, which is why we
do it a bit awkwardly. Additionally, `serializeForm` has no typechecking
for its return value (`return json as unknown as T`), and should be
refactored for type safety if at all possible.

There are at least two bugs we're solving in this commit:

1. Type checking fails on `serializeForm`, which results in
`expires: null` POSTed in a `UserServiceAccountRequest`, where it is not
allowed. The backend "correctly" returns a 400. For now we address this
by returning `undefined` from `serializeForm` on a `datetime-local`
input element when it is unset.

2. The schema allows for `expires: null` in `TokenModel`, but fails with
a 500 when that is actually sent. For now we address this with a `None`
check. (Note: this bug will not be encountered by the frontend after the
change from `null` to `undefined`, but it's still nice to fix.)

Both of these issues should eventually be solved by the backend handling
`ExpiringModel` in an `ExpiringModelSerializer` instead of the current
ad hoc way.

Introduced by #19561

Co-authored-by: Simonyi Gergő <gergo@goauthentik.io>
melizeche pushed a commit that referenced this pull request Feb 2, 2026
…#19913 to version-2025.12) (#19941)

core: fix non-expiring service accounts and app passwords (#19913)

core: fix datetime (de)?serialization

We aim to fix
#19911 in the next patch
release, so this commit shouldn't include an API change, which is why we
do it a bit awkwardly. Additionally, `serializeForm` has no typechecking
for its return value (`return json as unknown as T`), and should be
refactored for type safety if at all possible.

There are at least two bugs we're solving in this commit:

1. Type checking fails on `serializeForm`, which results in
`expires: null` POSTed in a `UserServiceAccountRequest`, where it is not
allowed. The backend "correctly" returns a 400. For now we address this
by returning `undefined` from `serializeForm` on a `datetime-local`
input element when it is unset.

2. The schema allows for `expires: null` in `TokenModel`, but fails with
a 500 when that is actually sent. For now we address this with a `None`
check. (Note: this bug will not be encountered by the frontend after the
change from `null` to `undefined`, but it's still nice to fix.)

Both of these issues should eventually be solved by the backend handling
`ExpiringModel` in an `ExpiringModelSerializer` instead of the current
ad hoc way.

Introduced by #19561

Co-authored-by: Dominic R <dominic@sdko.org>
Co-authored-by: Simonyi Gergő <gergo@goauthentik.io>
GirlBossRush pushed a commit that referenced this pull request Feb 3, 2026
…9561)

* web/forms: fix invalid date error for empty datetime-local inputs

Overview:

When a datetime-local input is empty, `valueAsNumber` returns `NaN` and `new Date("")` creates an Invalid Date. Previously, form serialization passed these invalid dates to the API, which caused  "RangeError: Invalid time value" when `toISOString()` was called. Now empty datetime inputs correctly serialize to `null`.

Testing:

1. Go to Directory > Tokens and App passwords
2. Create or edit a token
3. Uncheck the "Expiring" checkbox
4. Save the token
5. Verify no error occurs and token is saved without expiry

Motivation:

Closes: #19558

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

Labels

area:frontend Features or issues related to the browser, TypeScript, Node.js, etc backport/version-2025.10 Add this label to PRs to backport changes to version-2025.10 backport/version-2025.12 Add this label to PRs to backport changes to version-2025.12

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Unable to disable token expiry

2 participants