fix(migrator): resolve JwtOptions validation failure in Aspire orchestrator#1242
Merged
iammukeshm merged 2 commits intoMay 18, 2026
Merged
Conversation
added 2 commits
May 17, 2026 18:32
In local development (e.g. dotnet run or Aspire), the working directory is the project folder where the linked appsettings.json doesn't exist natively. This causes an OptionsValidationException for JwtOptions on startup, crashing Aspire with exit code -532462766. Loading from AppContext.BaseDirectory ensures the copied linked files are found.
…on in Aspire When running DbMigrator via Aspire (dotnet run), the working directory is the project directory, so appsettings.json is not found. This causes JwtOptions to fail ValidateOnStart. We now load appsettings.json from AppContext.BaseDirectory, and re-apply environment variables so Aspire connection strings are not overwritten.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where fsh-db-migrator silently crashes with OptionsValidationException when running via Aspire. In Aspire (dotnet run), the migrator's working directory is the project directory, so it fails to find appsettings.json (which is copied to the build output directory). Because IdentityModule registers JwtOptions with .ValidateOnStart(), the missing configuration causes the DI container build to fail entirely. Because AppHost.cs was recently updated to use .WaitForCompletion(migrator), this crash causes the fsh-api resource to wait indefinitely, hanging the entire Aspire orchestration. Fix: Explicitly load appsettings.json and appsettings.{Environment}.json from AppContext.BaseDirectory so that JwtOptions validation succeeds. Re-apply AddEnvironmentVariables() and AddCommandLine(args) immediately afterwards. This ensures that Aspire's dynamically injected environment variables maintain their intended priority and are not overridden by the hardcoded local connection strings in the loaded JSON files.