Skip to content

feat: take the network ID from config and refuse to start on any doubt - #21

Merged
dmakarenko merged 3 commits into
goodnotesfrom
kratos-network-id-from-config-20261027
Oct 28, 2026
Merged

dmakarenko merged 3 commits into
goodnotesfrom
kratos-network-id-from-config-20261027

Conversation

@dmakarenko

@dmakarenko dmakarenko commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

RegistryDefault.Init now takes the network from the config key network.id and refuses to start when the key is missing, is not a UUID, is the nil UUID, names no row in networks, or equals network.forbidden_id. It never creates a row, with one exception: for a memory SQLite DSN it inserts the configured row, because no other process can reach that database. migrate needs no key.

Why: the product Kratos releases must use their own network in the shared kratos_db, never the oldest row. Every later tag cut from goodnotes, classic too, needs network.id. The e2e runner and Playwright now set NETWORK_ID and run test/e2e/seed-network between migrate and serve. The quickstart*.yml files do not set it yet (tracked in kratos#fe5v).

Upstream check: ory/kratos master at b86338da04 still calls Determine in Init and has no config key for the network (searched driver/registry_default.go, driver/config, persistence/sql), so this is a local patch.

Tests: TestInitNetworkFromConfig covers SQLite, CockroachDB v23.1 and memory, and its config cases fail if a check is removed. driver, migratest, cmd/cleanup, cmd/courier, cmd/serve and examples pass. Real runs of serve, courier watch and cleanup sql exit 1 with no key and start with a valid key.

Product Kratos releases must use the network that config names, never
the oldest row in networks. Init now reads network.id (required except
for migrate) and network.forbidden_id (optional), and fails fast on a
missing, invalid, nil, forbidden or unknown network. No row is created.

Claude-Session: https://claude.ai/code/session_01LdtTNtaWbgWyKokPFfvUL3
…etry checks

A memory SQLite DSN lives only in this process, so nothing else can seed
its networks row and every non-migrate command refused to start. Init now
inserts the configured row for a memory DSN only, after all key checks,
and logs a warning. Config-error tests run against an unreachable DSN and
assert exact messages, so they fail if a check is removed or moved into
the retry. The cleanup sql help example sets NETWORK_ID.
The e2e runner and Playwright start Kratos with no network.id, so serve
refused to start. They now export a fixed NETWORK_ID and run the new
test/e2e/seed-network helper between migrate and serve. The helper
inserts the row once and skips it when the row exists.
@dmakarenko
dmakarenko merged commit fbc807c into goodnotes Oct 28, 2026
12 of 22 checks passed
@dmakarenko

Copy link
Copy Markdown
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant