Configuration problems
How the panel tells you about mistakes in your configuration
StellarAdmin doesn't crash your app over a configuration mistake. It works around it in the smallest way it can, and tells you what it did.
For example:
| Mistake | What happens |
|---|---|
| A default sort on a column that isn't sortable | The grid uses the data source's order. |
A PageSize that isn't in PageSizes | It's added to the page sizes. |
AllowCreate with a data source that can't create | There's no Create button, and the create page returns 404. |
| A field without a public setter | The field is left off the form. |
When there's nothing smaller to fall back to, like an EF Core entity no registered context maps, the whole resource is unavailable. It's hidden from the sidebar and the command palette, and its pages return 404. Your other resources, and the rest of your app, keep working.
Finding them
In Development, a pill at the bottom of every panel page counts the problems. Click it to see each one under the line of your code that caused it: what you'll notice, why, what the panel does instead, and how to fix it.
If a page looks incomplete, with a field, column, button or sidebar item missing, check the pill first.
Every environment also logs each problem once, in the StellarAdmin.Configuration category, with the file and line that configured it. Each kind of problem has its own event ID, so you can filter or alert on them.
| Level | Means |
|---|---|
| Error | The resource is unavailable. |
| Warning | Something you configured doesn't happen. |
| Information | It happens, but the panel adjusted something next to it. |
Most problems are found at startup. A few only show up when a page renders, like a lookup's EnableCreate for a resource without a create page. Those are logged the first time.
Settings
builder.Services.AddStellarAdmin(admin =>
{
admin.ConfigureDiagnostics(diagnostics =>
{
diagnostics.ShowIndicator = false;
diagnostics.ThrowOnProblems = builder.Environment.IsEnvironment("Testing");
});
});ShowIndicatorhides the pill. Problems are still logged.ThrowOnProblemsmakes startup throw an exception listing every problem. Turn it on in tests or CI, so a configuration mistake fails the build. Problems found while a page renders are only logged.
Reporting your own
If you configure resources in a post-configure callback, like a package that adds resources, report what you worked around with ReportProblem, ReportInfo or ReportUnavailable on ResourceOptions<T>:
using StellarAdmin.Resources.Options;
builder.Services.AddOptions<ResourceOptions<Booking>>().PostConfigure(options =>
{
foreach (var field in options.Create?.Fields.ToList() ?? [])
{
if (field.FieldName == "LegacyCode")
{
options.Create!.RemoveField(field);
options.ReportProblem(
new EventId(5001, "LegacyField"),
"The `LegacyCode` field isn't on the form because it can't be saved any more.",
"Remove the `LegacyCode` field from the create form.",
field);
}
}
});The message says what you notice, why, and what happens instead. Then comes the fix. Use backticks for code. StellarAdmin uses event IDs 1000 to 1099, so pick your own outside that range.