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

Improve writing dashboard startup config failure messages #3243

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Mar 28, 2024

Fixes #3168

  • Write configuration errors to logging instead of throwing exception
  • Add missing validation of frontend auth mode

Before:

image

After:

image

Microsoft Reviewers: Open in CodeFlow

@JamesNK
Copy link
Member Author

JamesNK commented Mar 28, 2024

@mitchdenny What does the host do on configuration or startup failure? We should think about consistency.

@davidfowl
Copy link
Member

@mitchdenny What does the host do on configuration or startup failure? We should think about consistency.

Can you do it in both places?

@mitchdenny
Copy link
Member

This is the way we do it in the AppHost:

_innerBuilder.Services.AddOptions<TransportOptions>().ValidateOnStart().PostConfigure(MapTransportOptionsFromCustomKeys);
_innerBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<TransportOptions>, TransportOptionsValidator>());

@JamesNK
Copy link
Member Author

JamesNK commented Apr 1, 2024

I want to register a type. I don't want to use a callback.

@JamesNK
Copy link
Member Author

JamesNK commented Apr 2, 2024

Review please 🙏

case FrontendAuthMode.OpenIdConnect:
break;
case null:
errorMessages.Add($"Frontend endpoint authentication is not configured. Either specify {DashboardConfigNames.DashboardUnsecuredAllowAnonymousName.ConfigKey}=true, or specify {DashboardConfigNames.DashboardFrontendAuthModeName.ConfigKey}. Possible values: {string.Join(", ", typeof(FrontendAuthMode).GetEnumNames())}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages should be localised.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do that then create a new issue. It's beyond the scope of this PR.

src/Aspire.Dashboard/Program.cs Outdated Show resolved Hide resolved
@JamesNK JamesNK force-pushed the jamesnk/dashboard-startup-error branch from f6a99ad to b926934 Compare April 3, 2024 05:10
@JamesNK JamesNK force-pushed the jamesnk/dashboard-startup-error branch from b926934 to 0469c0d Compare April 3, 2024 05:12
@JamesNK JamesNK merged commit b18a246 into main Apr 3, 2024
8 checks passed
@JamesNK JamesNK deleted the jamesnk/dashboard-startup-error branch April 3, 2024 08:45
@JamesNK
Copy link
Member Author

JamesNK commented Apr 3, 2024

/backport to release/8.0

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8535836985

Copy link
Contributor

github-actions bot commented Apr 3, 2024

@JamesNK backporting to release/8.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Improve writing dashboard startup config failure messages
Using index info to reconstruct a base tree...
M	src/Aspire.Dashboard/DashboardWebApplication.cs
M	tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs
Falling back to patching base and 3-way merge...
Auto-merging tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs
Auto-merging src/Aspire.Dashboard/DashboardWebApplication.cs
CONFLICT (content): Merge conflict in src/Aspire.Dashboard/DashboardWebApplication.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve writing dashboard startup config failure messages
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

github-actions bot commented Apr 3, 2024

@JamesNK an error occurred while backporting to release/8.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

radical pushed a commit to radical/aspire that referenced this pull request Apr 3, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make dashboard print a good error message when configuration is invalid
4 participants