[GH-ISSUE #4326] 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 #8441

Open
opened 2026-08-05 01:17:59 -04:00 by saavagebueno · 1 comment
Owner

Originally created by @MichaelUray on GitHub (Aug 11, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4326

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). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4326 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 2026-08-05 01:17:59 -04:00
Author
Owner

@cin3m commented on GitHub (Dec 30, 2025):

I also migrated to Postgres. I noticed that this behavior occurs on basically every setting related to the account settings:

2025-12-30T14:06:02Z ERRO [context: HTTP, requestID: d59toih9bor000bvmk2g, accountID: d1n8aep9bor000bgs000, userID: 36] management/server/store/sql_store.go:3583: failed to save account settings to store: failed to encode args[16]: unable to encode false into binary format for numeric (OID 1700): cannot find encode plan

Doesn't matter which setting I try to change within the account context.

Going back to SQlite for now and will try again in the future.

<!-- gh-comment-id:3699455006 --> @cin3m commented on GitHub (Dec 30, 2025): I also migrated to Postgres. I noticed that this behavior occurs on basically every setting related to the account settings: `2025-12-30T14:06:02Z ERRO [context: HTTP, requestID: d59toih9bor000bvmk2g, accountID: d1n8aep9bor000bgs000, userID: 36] management/server/store/sql_store.go:3583: failed to save account settings to store: failed to encode args[16]: unable to encode false into binary format for numeric (OID 1700): cannot find encode plan` Doesn't matter which setting I try to change within the account context. Going back to SQlite for now and will try again in the future.
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#8441