rebus-org / Rebus.PostgreSql

:bus: PostgreSQL persistence for Rebus
https://mookid.dk/category/rebus
Other
17 stars 19 forks source link

Not specifying "schemaName" throws exception. #44

Closed robert-misura-tfs closed 7 months ago

robert-misura-tfs commented 7 months ago

Hi, I am currently trying to update to .NET 8. My service keep crashing on ArgumentNull exception. I debuged the code and it turned out that in PostgreSqlSagaStorage in the constructor

public PostgreSqlSagaStorage(IPostgresConnectionProvider connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory, ISagaSerializer sagaSerializer, string schemaName = null)
    {
        if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
        _connectionHelper = connectionHelper ?? throw new ArgumentNullException(nameof(connectionHelper));
        _dataTableName = new TableName(schemaName ?? TableName.DefaultSchemaName, dataTableName ?? throw new ArgumentNullException(nameof(dataTableName)));
        _indexTableName = new TableName(schemaName, indexTableName ?? throw new ArgumentNullException(nameof(indexTableName)));
        _sagaSerializer = sagaSerializer;
        _log = rebusLoggerFactory.GetLogger<PostgreSqlSagaStorage>();
    }

The '_indexTableName', since schemaName is null, new TableName falls into the argument exception. I am aware of the default schema name in TableName but it keep falling into the argument exception.

   public TableName(string schema, string tableName)
    {
        if (schema == null) throw new ArgumentNullException(nameof(schema));
        if (tableName == null) throw new ArgumentNullException(nameof(tableName));

        Schema = StripQuotes(schema);
        Name = StripQuotes(tableName);
    }

I used to use it without schema name. It works when I add ... , schemaName: "public") at the end. Configuration of the saga:

  public static void ConfigureSagas(this StandardConfigurer<ISagaStorage> s, string postgresConnectionString)
  {
      s.StoreInPostgres(postgresConnectionString, "sagas", "sagas-index", true);
  }

Is it problem on my site ? Or did anything change and schema is required now ?

If schemaName is null, should it fall into the TableName controctor with default schemaName ? Also, I wonder, why it started to happen now ? Looks like that code was already there before, so I wonder what changed (except .NET 8)

PS: If owner still live in the Horsens, shoutout, I finished VIA UC in there 2 years ago.

mookid8000 commented 7 months ago

It's a bug 😅 just a second

mookid8000 commented 7 months ago

Could you try Rebus.PostgreSql 9.0.1 which is on NuGet.org now?

robert-misura-tfs commented 7 months ago

Looks like it is ok. Thank you.