jreyesr / steampipe-plugin-postgres

A Steampipe plugin that provides access to data stored in plain Postgres servers
Apache License 2.0
6 stars 2 forks source link

failed to initialise #2

Closed judell closed 1 year ago

judell commented 1 year ago
Warning:
    failed to start plugin 'hub.steampipe.io/plugins/jreyesr/postgres@latest': failed to plugin initialise plugin 'steampipe-plugin-postgres': TableMapFunc 'PluginTables' had unhandled error: interface conversion: interface is nil, not hclog.LoggerUpdatedConnections: true

I figured this must be a connection string problem, but I'm not seeing it.

My .spc:

 connection "postgres" {
  plugin = "jreyesr/postgres"

  # Write a connection string, in the form that is expected by the pgx package:
  # https://pkg.go.dev/github.com/jackc/pgx/v5#hdr-Establishing_a_Connection
  # Required
  connection_string = "postgres://jon:jon@localhost:5432/postgres"

  # The remote DB's schema that this plugin will expose
  # If you leave this unset, it'll default to `public`
  # schema = "public"
}

This works: psql -d postgres -U jon -W

I instrumented GetConfig like so:

func GetConfig(connection *plugin.Connection) PostgresConfig {
    logger.Debug("GetConfig", "connection", connection, "connection.Config", connection.Config)
    if connection == nil || connection.Config == nil {
        return PostgresConfig{}
    }
    config, other := connection.Config.(PostgresConfig)
    logger.Debug("GetConfig returning", "config", config, "other", other)
    return config
}

The output:

2023-09-11T10:40:59.563-0700 [DEBUG] plugin: postgres.PluginTables
2023-09-11T10:40:59.563-0700 [DEBUG] plugin: GetConfig: connection="&{postgres %!v(PANIC=String method: runtime error: invalid memory address or nil pointer d
ereference)}" connection.Config="%!v(PANIC=String method: runtime error: invalid memory address or nil pointer dereference)"
2023-09-11T10:40:59.563-0700 [DEBUG] plugin: GetConfig returning: config="%!v(PANIC=String method: runtime error: invalid memory address or nil pointer dereference)" other=true

I feel like I'm missing something really dumb?

jreyesr commented 1 year ago

Sorry, my bad! It's not the connection string, it's that the default schema is causing a null pointer. I didn't notice it because my .spc files do have a schema set.

Thanks for reporting this! Should be fixed