Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static codegen requires connection string (but doesn't need it) #3421

Closed
grzybsonssg opened this issue Sep 17, 2024 · 2 comments · Fixed by #3445
Closed

Static codegen requires connection string (but doesn't need it) #3421

grzybsonssg opened this issue Sep 17, 2024 · 2 comments · Fixed by #3445

Comments

@grzybsonssg
Copy link

When using static codegen from command line - something like ./MyApp.exe codegen write and app was built in Release configuration Marten requires that any connection string is provided. Otherwise it throws exception.
And I can't understand why.

This connection string can be anything out of the blue like server=google.or.anything.you.can.think.of.com;user id=postgres;password=not_a password;database=sth;Pooling=true;Persist Security Info=true and codegen works.

With empty connection string in appsettings it throws - tested with 7.27.0

$ ./MyApp.exe codegen write
Searching 'JasperFx.CodeGeneration.Commands, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' for commands
Searching 'Weasel.CommandLine, Version=7.5.0.0, Culture=neutral, PublicKeyToken=null' for commands
Searching 'Marten.CommandLine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' for commands


[red]ERROR:[/]System.ArgumentException: Host can't be null
  at void Npgsql.NpgsqlConnectionStringBuilder.PostProcessAndValidate()
  at NpgsqlDataSourceConfiguration Npgsql.NpgsqlSlimDataSourceBuilder.PrepareConfiguration()
  at NpgsqlDataSource Npgsql.NpgsqlSlimDataSourceBuilder.Build()
  at NpgsqlDataSource Npgsql.NpgsqlDataSourceBuilder.Build()
  at NpgsqlDataSource Weasel.Postgresql.Connections.DefaultNpgsqlDataSourceFactory.<.ctor>b__2_0(string connectionString
     )
  at TValue JasperFx.Core.Cache`2.get_Item(TKey key)
  at NpgsqlDataSource Weasel.Postgresql.Connections.DefaultNpgsqlDataSourceFactory.Create(string connectionString)
  at ITenancy Marten.StoreOptions.<>c__DisplayClass129_0.<Connection>b__0()
  at void System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
  at void System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
  at T System.Lazy`1.CreateValue()
  at ITenancy Marten.StoreOptions.get_Tenancy()
  at void Marten.StoreOptions.Validate()
  at Marten.DocumentStore..ctor(StoreOptions options)
(and so on)
@jeremydmiller
Copy link
Member

Feel like we've addressed this one a couple dozen times and it still crops up. Got it. Won't make 7.28 though

@jeremydmiller
Copy link
Member

Different than I though it was going to be. Something, something, law of unintended consequences. Fix in 7.29 tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants