Skip to content

Fix WithGlobalConnectionString silent failure with invalid connection strings#2157

Merged
jzabroski merged 6 commits into
mainfrom
copilot/fix-2115
Nov 12, 2025
Merged

Fix WithGlobalConnectionString silent failure with invalid connection strings#2157
jzabroski merged 6 commits into
mainfrom
copilot/fix-2115

Conversation

Copilot AI commented Sep 6, 2025

Copy link
Copy Markdown
Contributor
  • Add connection validation to MigrateUp method
  • Add unit tests for connection validation
  • Trigger CI workflow update
  • Fix unit test failures by moving mock setup after runner initialization
  • Trigger CI workflow again

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] WithGlobalConnectionString with invalid connection string silently fails without error or warning Fix WithGlobalConnectionString silent failure with invalid connection strings Sep 6, 2025
Copilot AI requested a review from jzabroski September 6, 2025 21:41
@PhenX

PhenX commented Sep 11, 2025

Copy link
Copy Markdown
Collaborator

Simply opening the connection would validate the connection string no ? Is there an advantage to also open an empty transaction ?

@jzabroski

Copy link
Copy Markdown
Collaborator

@copilot Update this PR to trigger an updated GitHub Action for the PR.

Co-authored-by: jzabroski <[email protected]>

Copilot AI commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Update this PR to trigger an updated GitHub Action for the PR.

Done. Added a trivial change in commit e59bd4c to trigger the GitHub Actions workflow.

@github-actions

github-actions Bot commented Nov 11, 2025

Copy link
Copy Markdown

Test Results

    1 files      1 suites   37s ⏱️
5 341 tests 5 009 ✅ 332 💤 0 ❌
5 822 runs  5 226 ✅ 596 💤 0 ❌

Results for commit e5d2a3b.

♻️ This comment has been updated with latest results.

@jzabroski

Copy link
Copy Markdown
Collaborator

@copilot Please address the failing unit test. The following unit test for this PR fails when running on our AzureDevOps release build; the result is it throws System.ArgumentException : Invalid connection string :
FluentMigrator.Tests.Unit.MigrationRunnerTests.MigrateUpShouldValidateConnectionAndThrowExceptionForInvalidConnectionString

Below is the stack trace:

at Moq.Behaviors.ThrowException.Execute(Invocation invocation) in //src/Moq/Behaviors/ThrowException.cs:line 22
at Moq.MethodCall.ExecuteCore(Invocation invocation) in /
/src/Moq/MethodCall.cs:line 109
at Moq.Setup.Execute(Invocation invocation) in //src/Moq/Setup.cs:line 86
at Moq.FindAndExecuteMatchingSetup.Handle(Invocation invocation, Mock mock) in /
/src/Moq/Interception/InterceptionAspects.cs:line 96
at Moq.Mock.Moq.IInterceptor.Intercept(Invocation invocation) in //src/Moq/Interception/Mock.cs:line 15
at Moq.CastleProxyFactory.Interceptor.Intercept(IInvocation underlying) in /
/src/Moq/Interception/CastleProxyFactory.cs:line 113
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at FluentMigrator.Runner.MigrationScopeHandler.BeginScope() in \src\FluentMigrator.Runner.Core\MigrationScopeHandler.cs:line 49
at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(IMigrationInfo migrationInfo, Boolean useTransaction) in \src\FluentMigrator.Runner.Core\MigrationRunner.cs:line 538
at FluentMigrator.Runner.VersionLoader.LoadVersionInfo() in \src\FluentMigrator.Runner.Core\VersionLoader.cs:line 179
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue()
at FluentMigrator.Tests.Unit.MigrationRunnerTests.CreateRunner(Action`1 initAction) in \test\FluentMigrator.Tests\Unit\MigrationRunnerTests.cs:line 121
at FluentMigrator.Tests.Unit.MigrationRunnerTests.MigrateUpShouldValidateConnectionEvenWhenNoMigrationsToApply() in \test\FluentMigrator.Tests\Unit\MigrationRunnerTests.cs:line 867

Copilot AI commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Please address the failing unit test. The following unit test for this PR fails when running on our AzureDevOps release build; the result is it throws System.ArgumentException : Invalid conne...

Fixed in commit 4b5348d. The issue was that the mock setup for BeginTransaction() was being configured before CreateRunner(), causing the exception to be thrown during runner initialization when VersionLoader was being lazily loaded. The fix moves the mock setup to after the runner is created, ensuring the exception is only thrown during the validation call in MigrateUp().

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pyvvsblobprodsu6weus63.blob.core.windows.net
    • Triggering command: dotnet restore --no-dependencies /home/REDACTED/work/fluentmigrator/fluentmigrator/FluentMigrator.sln --packages /home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot (dns block)
    • Triggering command: dotnet restore --no-dependencies /home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/B403A62E9ABF9F258DBC8B533BE3E455/missingpackages_workingdir --packages /home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/fluentmigrator/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@jzabroski

Copy link
Copy Markdown
Collaborator

@copilot Please make a trivial change to trigger a new GitHub action workflow on this PR.

Co-authored-by: jzabroski <[email protected]>

Copilot AI commented Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Please make a trivial change to trigger a new GitHub action workflow on this PR.

Done. Added a trivial change in commit e5d2a3b to trigger the GitHub Actions workflow.

@jzabroski jzabroski added this to the 7.2.0 milestone Nov 12, 2025
@jzabroski
jzabroski marked this pull request as ready for review November 12, 2025 23:34
@jzabroski
jzabroski merged commit b41c42b into main Nov 12, 2025
6 checks passed
@jzabroski
jzabroski deleted the copilot/fix-2115 branch November 12, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants