401 on dashboard after migrating datastore to postgres from sqlite #1097

Closed
opened 2025-11-20 05:23:58 -05:00 by saavagebueno · 1 comment
Owner

Originally created by @Markovich01 on GitHub (Jul 26, 2024).

Describe the problem

management/server/http/middleware/auth_middleware.go:89: Error when validating JWT claims: ERROR: update or delete on table "accounts" violates foreign key constraint "rules_account_id_fkey" on table "rules" (SQLSTATE 23503)
management/server/http/util/util.go:81: got a handler error: token invalid

To Reproduce

Steps to reproduce the behavior:

  1. Migrate sqlite datastore to postgres as per docs
  2. Auth as usual to NetBird dashboard via Keycloak
  3. See error in browser (see image) and docker log (see above)

Expected behavior

200 response and NetBird dashboard loads as usual

Are you using NetBird Cloud?

No

NetBird version

0.28.6

NetBird status -d output:

N/A

Screenshots

N/A

Additional context

Previously migrated from JSON datastore to sqlite. Only one account with five users, one rule, ten groups and JWT groups disabled.

Originally created by @Markovich01 on GitHub (Jul 26, 2024). **Describe the problem** ``` management/server/http/middleware/auth_middleware.go:89: Error when validating JWT claims: ERROR: update or delete on table "accounts" violates foreign key constraint "rules_account_id_fkey" on table "rules" (SQLSTATE 23503) management/server/http/util/util.go:81: got a handler error: token invalid ``` **To Reproduce** Steps to reproduce the behavior: 1. Migrate sqlite datastore to postgres as per docs 2. Auth as usual to NetBird dashboard via Keycloak 3. See error in browser (see image) and docker log (see above) **Expected behavior** 200 response and NetBird dashboard loads as usual **Are you using NetBird Cloud?** No **NetBird version** 0.28.6 **NetBird status -d output:** N/A **Screenshots** N/A **Additional context** Previously migrated from JSON datastore to sqlite. Only one account with five users, one rule, ten groups and JWT groups disabled.
saavagebueno added the triage-needed label 2025-11-20 05:23:58 -05:00
Author
Owner

@Markovich01 commented on GitHub (Aug 6, 2024):

Seems like the rules table is a leftover from previous versions of the management server. If I am correct, you may want to add a note to the postgres migration page that you may need to remove the rules table in addition to the sorting out the lack of cascading deletes.

(Copied from Slack)

@Markovich01 commented on GitHub (Aug 6, 2024): Seems like the `rules` table is a leftover from previous versions of the management server. If I am correct, you may want to add a note to the postgres migration page that you may need to remove the `rules` table in addition to the sorting out the lack of cascading deletes. _(Copied from Slack)_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1097