Skip to content

Conversation

@jakubno
Copy link
Member

@jakubno jakubno commented Jan 22, 2026

Note

Adds a separate auth database client with optional read-replica and refactors services to use it.

  • New packages/db/pkg/auth client exposing Read/Write query sets; shared pool for PG connections; client.NewClient signature now requires a connection string
  • API switches auth-related queries to authdb (Read for lookups, Write for mutations); updates config to support AUTH_DB_CONNECTION_STRING and AUTH_DB_READ_REPLICA_CONNECTION_STRING with pool sizing
  • Nomad job exports new env vars and forwards read-replica secret; Terraform creates postgres-read-replica-connection-string secret and plumbs it through modules
  • Reverse proxy validates access tokens via authdb; tests and seed scripts updated to use new clients; added packages/db seed-db target and referenced from self-host docs
  • Minor: move build→machine info mapping to packages/db/pkg/builds; adjust imports and go.mod entries

Written by Cursor Bugbot for commit 72ac884. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Jan 22, 2026

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ebcccb8f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3
github.com/bits-and-blooms/bitset v1.22.0
github.com/dchest/uniuri v1.2.0
github.com/e2b-dev/infra/packages/db v0.0.0-20251013083250-eb6cd250d671
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to remove the shared dependency on db (it was circular)

}
}

func FromDB(build queries.EnvBuild) MachineInfo {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to db package

Copy link
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, jsut few nits

authDB, err := authdb.NewClient(
ctx,
config.AuthDBConnectionString,
config.AuthDBReadReplicaConnectionString,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I understand correctly that if this is "" the AuthDBConnectionString will be used instead?


func NewClient(ctx context.Context, databaseURL, replicaURL string, options ...pool.Option) (*Client, error) {
if strings.TrimSpace(databaseURL) == "" {
logger.L().Error(ctx, "POSTGRES_CONNECTION_STRING is required")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this log line? Also, is the POSTGRES_CONNECTION_STRING valid requirement here?

readPool, err = pool.New(ctx, replicaURL, options...)
if err != nil {
writePool.Close()
logger.L().Error(ctx, "Unable to create read connection pool", zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably don't need this log line either

package: "authqueries"
out: "pkg/auth/queries/"
sql_package: "pgx/v5"
overrides:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need all of these override in the auth db?

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.

3 participants