Error: JWT Token Is Invalid in dbt Transformations
Issue
Transformation runs for dbt projects connected to Snowflake intermittently fail. The following error appears:
JWT token is invalid
If connection setup tests fail with this error instead, see Error: JWT Token Is Invalid.
Environment
- Transformations: Transformations for dbt
- Destination: Snowflake
- Authentication: Key-pair authentication with an encrypted private key
Resolution
To resolve this issue:
- Confirm that the private key is up-to-date and not expired.
- In Fivetran, go to Transformations > Manage projects.
- Click the more options menu icon next to your project, then select Edit connection settings.
- Under Environment Variables, click + Add. Then, add
JWT_LIFETIME_IN_SECONDS=300to extend the token lifetime. - Select Save & Test.
- Run your transformations to confirm that the error is resolved.
If the error persists, review the logs for patterns or timestamps that indicate token expiry.
Cause
This issue occurs when the JWT token expires before it reaches Snowflake. Snowflake enforces a short JWT validity window, so tokens can expire before it processes them. Clock drift, network latency, or delays in job processing can cause this.