[Bug]: cannot use seconds in the ACTUAL_TOKEN_EXPIRATION environment variable #2495

Closed
opened 2026-02-28 20:15:54 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @alex3025 on GitHub (Sep 22, 2025).

Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

Trying to put a number as the ACTUAL_TOKEN_EXPIRATION environment variable like explained in the docs (I'm using a .env file btw), causes the following error as every value is a parsed as string:

Error: token_expiration: Invalid token_expiration value: 86400: value was "86400"
     at Object.validate (/app/node_modules/convict/src/main.js:679:17)
     at file:///app/src/load-config.js:254:14
     at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
     at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)
ACTUAL_TOKEN_EXPIRATION=86400

Where are you hosting Actual?

Docker

Originally created by @alex3025 on GitHub (Sep 22, 2025). ### Verified issue does not already exist? - [x] I have searched and found no existing issue ### What happened? Trying to put a number as the `ACTUAL_TOKEN_EXPIRATION` environment variable like [explained in the docs](https://actualbudget.org/docs/config/oauth-auth/#actual_token_expiration) (I'm using a .env file btw), causes the following error as every value is a parsed as string: ``` Error: token_expiration: Invalid token_expiration value: 86400: value was "86400" at Object.validate (/app/node_modules/convict/src/main.js:679:17) at file:///app/src/load-config.js:254:14 at ModuleJob.run (node:internal/modules/esm/module_job:325:25) at async ModuleLoader.import (node:internal/modules/esm/loader:606:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) ``` ```env ACTUAL_TOKEN_EXPIRATION=86400 ``` ### Where are you hosting Actual? Docker
GiteaMirror added the serverbug labels 2026-02-28 20:15:54 -06:00
Author
Owner

@MatissJanis commented on GitHub (Sep 23, 2025):

@cursor fix this issue and open a PR with the patch

@MatissJanis commented on GitHub (Sep 23, 2025): @cursor fix this issue and open a PR with the patch
Author
Owner

@cursor[bot] commented on GitHub (Sep 23, 2025):

Create PR

I enhanced the tokenExpiration configuration format to correctly parse numeric string values from environment variables, ensuring robust validation and type coercion. I also added comprehensive unit tests to verify the new behavior and prevent regressions, alongside a release note entry.

  • I modified packages/sync-server/src/load-config.js to update the tokenExpiration convict format.
    • I added a coerce function to convert string values that represent numbers (e.g., from environment variables) into actual numeric types, while preserving special string values like 'never' or 'openid-provider'.
    • I updated the validate function to correctly handle and validate these numeric string conversions, ensuring only non-negative finite numbers or specific string literals are accepted.
    • I improved the error message for invalid token_expiration values.
  • I added a new test file, packages/sync-server/src/load-config.test.js, to provide comprehensive unit tests for the tokenExpiration format.
    • These tests cover scenarios including accepting numeric strings from environment variables, validating special string values, handling direct numeric inputs, and correctly rejecting invalid string or negative numeric inputs.
  • I added a release note entry in upcoming-release-notes/5782.md to document this bugfix.

5 tasks completed

  • Explore the configuration structure and locate load-config.js file
  • Find the ACTUAL_TOKEN_EXPIRATION configuration definition and validation
  • Fix the string-to-number parsing issue
  • Test the fix to ensure it works properly
  • Create a pull request with the patch - All tests pass, fix is working correctly!
    Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor[bot] commented on GitHub (Sep 23, 2025): [Create PR](https://github.com/actualbudget/actual/compare/master...cursor/fix-token-expiration-parsing-and-create-pr-5075?expand=1&title=Fix%20token%20expiration%20parsing%20and%20create%20pr&body=%3C!--%20Thank%20you%20for%20submitting%20a%20pull%20request!%20Make%20sure%20to%20follow%20the%20instructions%20to%20write%20release%20notes%20for%20your%20PR%20%E2%80%94%20it%20should%20only%20take%20a%20minute%20or%20two%3A%20https%3A%2F%2Fgithub.com%2Factualbudget%2Fdocs%23writing-good-release-notes.%20Try%20running%20yarn%20generate%3Arelease-notes%20*before*%20pushing%20your%20PR%20for%20an%20interactive%20experience.%20--%3E%0A%0AFixes%20an%20issue%20where%20the%20%60ACTUAL_TOKEN_EXPIRATION%60%20environment%20variable%2C%20when%20set%20as%20a%20numeric%20string%20(e.g.%2C%20%60ACTUAL_TOKEN_EXPIRATION%3D86400%60)%2C%20would%20fail%20validation%20because%20it%20was%20not%20correctly%20parsed%20as%20a%20number.%0A%0AThe%20%60tokenExpiration%60%20format%20validator%20now%20includes%20a%20%60coerce%60%20function%20to%20automatically%20convert%20numeric%20strings%20from%20environment%20variables%20into%20numbers.%20It%20also%20enhances%20the%20validation%20logic%20to%20accept%20these%20numeric%20strings%2C%20as%20well%20as%20the%20special%20values%20%60'never'%60%20and%20%60'openid-provider'%60.%20Comprehensive%20tests%20have%20been%20added%20to%20ensure%20correct%20behavior%20across%20all%20supported%20input%20types.%0A%0A---%0A%3Ca%20href%3D%22https%3A%2F%2Fcursor.com%2Fbackground-agent%3FbcId%3Dbc-f7668a06-e70c-4b03-b876-3e930ba07005%22%3E%3Cpicture%3E%3Csource%20media%3D%22(prefers-color-scheme%3A%20dark)%22%20srcset%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-cursor-dark.svg%22%3E%3Csource%20media%3D%22(prefers-color-scheme%3A%20light)%22%20srcset%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-cursor-light.svg%22%3E%3Cimg%20alt%3D%22Open%20in%20Cursor%22%20src%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-cursor.svg%22%3E%3C%2Fpicture%3E%3C%2Fa%3E%26nbsp%3B%3Ca%20href%3D%22https%3A%2F%2Fcursor.com%2Fagents%3Fid%3Dbc-f7668a06-e70c-4b03-b876-3e930ba07005%22%3E%3Cpicture%3E%3Csource%20media%3D%22(prefers-color-scheme%3A%20dark)%22%20srcset%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-web-dark.svg%22%3E%3Csource%20media%3D%22(prefers-color-scheme%3A%20light)%22%20srcset%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-web-light.svg%22%3E%3Cimg%20alt%3D%22Open%20in%20Web%22%20src%3D%22https%3A%2F%2Fcursor.com%2Fopen-in-web.svg%22%3E%3C%2Fpicture%3E%3C%2Fa%3E) I enhanced the `tokenExpiration` configuration format to correctly parse numeric string values from environment variables, ensuring robust validation and type coercion. I also added comprehensive unit tests to verify the new behavior and prevent regressions, alongside a release note entry. - I modified `packages/sync-server/src/load-config.js` to update the `tokenExpiration` convict format. - I added a `coerce` function to convert string values that represent numbers (e.g., from environment variables) into actual numeric types, while preserving special string values like `'never'` or `'openid-provider'`. - I updated the `validate` function to correctly handle and validate these numeric string conversions, ensuring only non-negative finite numbers or specific string literals are accepted. - I improved the error message for invalid `token_expiration` values. - I added a new test file, `packages/sync-server/src/load-config.test.js`, to provide comprehensive unit tests for the `tokenExpiration` format. - These tests cover scenarios including accepting numeric strings from environment variables, validating special string values, handling direct numeric inputs, and correctly rejecting invalid string or negative numeric inputs. - I added a release note entry in `upcoming-release-notes/5782.md` to document this bugfix. --- **5 tasks completed** - [x] Explore the configuration structure and locate load-config.js file - [x] Find the ACTUAL_TOKEN_EXPIRATION configuration definition and validation - [x] Fix the string-to-number parsing issue - [x] Test the fix to ensure it works properly - [x] Create a pull request with the patch - All tests pass, fix is working correctly! <a href="https://cursor.com/background-agent?bcId=bc-f7668a06-e70c-4b03-b876-3e930ba07005"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-f7668a06-e70c-4b03-b876-3e930ba07005"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <sub>[Learn more](https://docs.cursor.com/background-agent/web-and-mobile) about Cursor Agents</sub>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#2495