ory / oathkeeper

A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API that authenticates, authorizes, and mutates incoming HTTP(s) requests. Inspired by the BeyondCorp / Zero Trust white paper. Written in Go.

Home Page:https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=hydra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Middleware initializes pgx/v4

rlorca opened this issue · comments

Preflight checklist

Describe the bug

Hi,

I'm a new user, trying to add oathkeeper middleware to a gRPC service, but the application crashes during startup, before any explicit call to oathkeeper code.

As shown in the logs below, sql driver 'pgx' is being registered twice, once by the app and again by the middleware.

My application uses pgx v5, but one of oathkeeper's dependencies (x/watcherx) is loading v4, as shown by 'mod why':

  • github.com/ory/oathkeeper/middleware
  • github.com/ory/oathkeeper/driver/configuration
  • github.com/ory/x/watcherx
  • github.com/jackc/pgx/v4/stdlib

Any help would be appreciated.

Rodrigo

Reproducing the bug

  • In a project using pgx v5
  • Import "github.com/ory/oathkeeper/middleware"

Relevant log output

panic: sql: Register called twice for driver pgx

goroutine 1 [running]:
database/sql.Register({0x2ae2b40, 0x3}, {0x2dfade0, 0xc000010258})
        /go/go1.20/src/database/sql/sql.go:51 +0x225
github.com/jackc/pgx/v4/stdlib.init.0()
        /go/pkg/mod/github.com/jackc/pgx/v4@v4.17.2/stdlib/sql.go:87 +0x11a
Exiting.

Relevant configuration

No response

Version

v0.40.1

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Other

Additional Context

No response

Maybe this can help jackc/pgx#1480