Sqlite to Postgres migration caused issue - failed to encode args[15]: unable to encode true into binary format for numeric (OID 1700) - when changing session expiration days #2172

Open
opened 2025-11-20 07:05:11 -05:00 by saavagebueno · 0 comments
Owner

Originally created by @MichaelUray on GitHub (Aug 11, 2025).

After a migration from Sqlite to Postgres I experienced the following error when I tried to change the session expiration days:

management-1  | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e, accountID: d1ugaajkp1rs739cm0o0, userID: 9310074d-c4ea-4a5f-bf92-9c359af6457a] management/server/store/sql_store.go:2336: failed to save account settings to store: failed to encode args[15]: unable to encode true into binary format for numeric (OID 1700): cannot find encode plan
management-1  | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e, accountID: d1ugaajkp1rs739cm0o0, userID: 9310074d-c4ea-4a5f-bf92-9c359af6457a] shared/management/http/util/util.go:85: got a handler error: failed to save account settings to store
management-1  | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e] management/server/telemetry/http_api_metrics.go:189: HTTP response 737ca23e-13af-4419-86b4-2a2321ebb35e: PUT /api/accounts/d1ugaajkp1rs739cm0o0 status 500

That SQL statment fixed it:

BEGIN;

-- 1) alten Default entfernen
ALTER TABLE accounts
  ALTER COLUMN settings_lazy_connection_enabled DROP DEFAULT;

-- 2) Typ konvertieren (0/NULL -> false, ≠0 -> true)
ALTER TABLE accounts
  ALTER COLUMN settings_lazy_connection_enabled
  TYPE boolean
  USING (COALESCE(settings_lazy_connection_enabled, 0) <> 0);

-- 3) Nulls auf false setzen (nur falls vorhanden)
UPDATE accounts
  SET settings_lazy_connection_enabled = false
  WHERE settings_lazy_connection_enabled IS NULL;

-- 4) neuen Default + NOT NULL setzen
ALTER TABLE accounts
  ALTER COLUMN settings_lazy_connection_enabled SET DEFAULT false,
  ALTER COLUMN settings_lazy_connection_enabled SET NOT NULL;

COMMIT;

NetBird version
Docker, selfhosted.
netbird-mgmt version 0.54.0

Originally created by @MichaelUray on GitHub (Aug 11, 2025). After a migration from Sqlite to Postgres I experienced the following error when I tried to change the session expiration days: ``` management-1 | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e, accountID: d1ugaajkp1rs739cm0o0, userID: 9310074d-c4ea-4a5f-bf92-9c359af6457a] management/server/store/sql_store.go:2336: failed to save account settings to store: failed to encode args[15]: unable to encode true into binary format for numeric (OID 1700): cannot find encode plan management-1 | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e, accountID: d1ugaajkp1rs739cm0o0, userID: 9310074d-c4ea-4a5f-bf92-9c359af6457a] shared/management/http/util/util.go:85: got a handler error: failed to save account settings to store management-1 | 2025-08-11T08:50:54Z ERRO [context: HTTP, requestID: 737ca23e-13af-4419-86b4-2a2321ebb35e] management/server/telemetry/http_api_metrics.go:189: HTTP response 737ca23e-13af-4419-86b4-2a2321ebb35e: PUT /api/accounts/d1ugaajkp1rs739cm0o0 status 500 ``` That SQL statment fixed it: ``` BEGIN; -- 1) alten Default entfernen ALTER TABLE accounts ALTER COLUMN settings_lazy_connection_enabled DROP DEFAULT; -- 2) Typ konvertieren (0/NULL -> false, ≠0 -> true) ALTER TABLE accounts ALTER COLUMN settings_lazy_connection_enabled TYPE boolean USING (COALESCE(settings_lazy_connection_enabled, 0) <> 0); -- 3) Nulls auf false setzen (nur falls vorhanden) UPDATE accounts SET settings_lazy_connection_enabled = false WHERE settings_lazy_connection_enabled IS NULL; -- 4) neuen Default + NOT NULL setzen ALTER TABLE accounts ALTER COLUMN settings_lazy_connection_enabled SET DEFAULT false, ALTER COLUMN settings_lazy_connection_enabled SET NOT NULL; COMMIT; ``` **NetBird version** Docker, selfhosted. netbird-mgmt version 0.54.0
saavagebueno added the triage-needed label 2025-11-20 07:05:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#2172