Skip to content

Invalid credentials in VCAP_SERVICES crash Host Startup #1678

@batje

Description

@batje

Describe the bug

With the VCAP_SERVICE from issue #1676 but the tag 'postgresql' added to the list of tags, the startup of the Host fails spectacularly.

Steps to reproduce

  1. Configure a service on you application that uses the work 'host' instead of 'hostname' in the credentials

1.these are the calles to Steeltoe done before running the app:

             builder.AddCloudFoundryConfiguration();
            builder.Configuration.AddCloudFoundry();
            builder.AddPostgreSql();
 call app.Run();

the result:

15:57:35.293: [APP/PROC/WEB.0]       Application startup exception
15:57:35.293: [APP/PROC/WEB.0]       System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
15:57:35.293: [APP/PROC/WEB.0]        ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
15:57:35.293: [APP/PROC/WEB.0]        ---> System.ArgumentNullException: Value cannot be null. (Parameter 'Host')
15:57:35.293: [APP/PROC/WEB.0]          at System.ArgumentNullException.Throw(String paramName)
15:57:35.293: [APP/PROC/WEB.0]          at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
15:57:35.293: [APP/PROC/WEB.0]          at System.ArgumentException.ThrowNullOrWhiteSpaceException(String argument, String paramName)
15:57:35.293: [APP/PROC/WEB.0]          at System.ArgumentException.ThrowIfNullOrWhiteSpace(String argument, String paramName)
15:57:35.293: [APP/PROC/WEB.0]          at Npgsql.NpgsqlConnectionStringBuilder.PostProcessAndValidate()
15:57:35.293: [APP/PROC/WEB.0]          at Npgsql.NpgsqlConnection.SetupDataSource()
15:57:35.293: [APP/PROC/WEB.0]          at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
15:57:35.293: [APP/PROC/WEB.0]          at Npgsql.NpgsqlConnection..ctor(String connectionString)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
15:57:35.293: [APP/PROC/WEB.0]          --- End of inner exception stack trace ---
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
15:57:35.293: [APP/PROC/WEB.0]          at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Common.DynamicTypeAccess.TypeAccessor.CreateInstance(Object[] arguments) in /_/src/Common/src/Common/DynamicTypeAccess/TypeAccessor.cs:line 27
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.PostgreSql.DynamicTypeAccess.NpgsqlConnectionShim.CreateInstance(PostgreSqlPackageResolver packageResolver, String connectionString) in /_/src/Connectors/src/Connectors/PostgreSql/DynamicTypeAccess/NpgsqlConnectionShim.cs:line 23
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.PostgreSql.PostgreSqlServiceCollectionExtensions.CreateConnection(IServiceProvider serviceProvider, String serviceBindingName, PostgreSqlPackageResolver packageResolver) in /_/src/Connectors/src/Connectors/PostgreSql/PostgreSqlServiceCollectionExtensions.cs:line 117
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.PostgreSql.PostgreSqlServiceCollectionExtensions.<>c__DisplayClass2_0.<AddPostgreSql>b__0(IServiceProvider serviceProvider, String serviceBindingName) in /_/src/Connectors/src/Connectors/PostgreSql/PostgreSqlServiceCollectionExtensions.cs:line 68
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.Connector`2.<>c__DisplayClass9_0.<.ctor>b__0() in /_/src/Connectors/src/Connectors/Connector.cs:line 75
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.Connector`2.CreateConnection() in /_/src/Connectors/src/Connectors/Connector.cs:line 133
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.Connector`2.GetConnection() in /_/src/Connectors/src/Connectors/Connector.cs:line 95
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
15:57:35.293: [APP/PROC/WEB.0]          --- End of inner exception stack trace ---
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
15:57:35.293: [APP/PROC/WEB.0]          at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Common.DynamicTypeAccess.ReflectionAccessor.InvokeMethod(String name, Boolean isPublic, Object instance, Object[] arguments) in /_/src/Common/src/Common/DynamicTypeAccess/ReflectionAccessor.cs:line 114
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Common.DynamicTypeAccess.InstanceAccessor.InvokeMethod(String name, Boolean isPublic, Object[] arguments) in /_/src/Common/src/Common/DynamicTypeAccess/InstanceAccessor.cs:line 63
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.DynamicTypeAccess.ConnectorShim`1.GetConnection() in /_/src/Connectors/src/Connectors/DynamicTypeAccess/ConnectorShim.cs:line 28
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.PostgreSql.PostgreSqlServiceCollectionExtensions.CreateHealthContributor(IServiceProvider serviceProvider, String serviceBindingName, PostgreSqlPackageResolver packageResolver) in /_/src/Connectors/src/Connectors/PostgreSql/PostgreSqlServiceCollectionExtensions.cs:line 95
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.PostgreSql.PostgreSqlServiceCollectionExtensions.<>c__DisplayClass2_0.<AddPostgreSql>b__1(IServiceProvider serviceProvider, String serviceBindingName) in /_/src/Connectors/src/Connectors/PostgreSql/PostgreSqlServiceCollectionExtensions.cs:line 69
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Connectors.ConnectorOptionsBinder.<>c__DisplayClass2_0.<RegisterHealthContributor>b__0(IServiceProvider serviceProvider) in /_/src/Connectors/src/Connectors/ConnectorOptionsBinder.cs:line 78
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
15:57:35.293: [APP/PROC/WEB.0]          at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Management.Endpoint.ActuatorRouteBuilderExtensions.MapActuators(IEndpointRouteBuilder builder) in /_/src/Management/src/Endpoint/ActuatorRouteBuilderExtensions.cs:line 29
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Management.Endpoint.ApplicationBuilderExtensions.<>c__DisplayClass1_0.<UseActuatorEndpoints>b__0(IEndpointRouteBuilder endpoints) in /_/src/Management/src/Endpoint/ApplicationBuilderExtensions.cs:line 58
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Management.Endpoint.ApplicationBuilderExtensions.UseActuatorEndpoints(IApplicationBuilder builder, Action`1 configureEndpoints) in /_/src/Management/src/Endpoint/ApplicationBuilderExtensions.cs:line 56
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Management.Endpoint.ApplicationBuilderExtensions.UseActuatorEndpoints(IApplicationBuilder builder) in /_/src/Management/src/Endpoint/ApplicationBuilderExtensions.cs:line 27
15:57:35.293: [APP/PROC/WEB.0]          at Steeltoe.Management.Endpoint.ConfigureActuatorsMiddlewareStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app) in /_/src/Management/src/Endpoint/ConfigureActuatorsMiddlewareStartupFilter.cs:line 38
15:57:35.293: [APP/PROC/WEB.0]          at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
15:57:35.294: [APP/PROC/WEB.0] fail: Microsoft.Extensions.Hosting.Internal.Host[11]
15:57:35.294: [APP/PROC/WEB.0]       Hosting failed to start

Expected behavior

A shorter more descriptive error message about an invalid connectionstring.

Environment (please complete the following information):

  • Steeltoe Version 4.1.0
  • Platform: Cloud Foundry (stackit)
  • OS: linux
  • .NET Version 10
  • Any other library versions to note

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions