Skip to content

Add endpoint metadata to developer exception page #52668

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

Merged

Conversation

Kahbazi
Copy link
Member

@Kahbazi Kahbazi commented Dec 8, 2023

Fixes #48208

image

@ghost ghost added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member labels Dec 8, 2023
@ghost
Copy link

ghost commented Dec 8, 2023

Thanks for your PR, @Kahbazi. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@Kahbazi Kahbazi added feature-diagnostics Diagnostic middleware and pages (except EF diagnostics) and removed area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Dec 8, 2023
{
<tr>
<td>@metadata.GetType().Name</td>
<td>@(metadata.ToString())</td>
Copy link
Member

Choose a reason for hiding this comment

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

Does Razor escape HTML by default? I want to make sure that a ToString result that returns HTML doesn't accidently break the page.

Copy link
Member

Choose a reason for hiding this comment

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

Also, what happens if metadata has new lines? They should be kept when displayed on the web page.

Copy link
Member

Choose a reason for hiding this comment

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

I think HtmlEncodeAndReplaceLineBreaks (which the title above uses) should be called here.

{
<p>@Resources.ErrorPageHtml_NoRouteValues</p>
}
<h2>@Resources.ErrorPageHtml_Metadata</h2>
Copy link
Member

@JamesNK JamesNK Dec 13, 2023

Choose a reason for hiding this comment

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

The endpoint metadata section is very related to the endpoint section. Either it should be:

  • nested in the endpoint section, e.g. Metadata has an h3 or h4 title.
  • or the metadata section should be below the endpoint section and the title should be Endpoint Metadata. If there is no endpoint then there is no need to also say there is no endpoint metadata.

<p>@Resources.ErrorPageHtml_NoRouteValues</p>
}
<h2>@Resources.ErrorPageHtml_Metadata</h2>
@if (Model.Endpoint?.Metadata != null)
Copy link
Member

Choose a reason for hiding this comment

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

Also check that the collection isn't empty, e.g. @if (Model.Endpoint?.Metadata.Count > 0) { ... }

@JamesNK
Copy link
Member

JamesNK commented Dec 13, 2023

Overall, looks good. Just a few changes needed.

@foreach (var metadata in Model.Endpoint.Metadata)
{
<tr>
<td>@metadata.GetType().Name</td>
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the full type name as a tooltip.

Something like:

Suggested change
<td>@metadata.GetType().Name</td>
<td><span title="@metadata.GetType().FullName">@metadata.GetType().Name<span></td>

(untested)

<th>@Resources.ErrorPageHtml_VariableColumn</th>
<th>@Resources.ErrorPageHtml_ValueColumn</th>
<td><span title="@metadata.GetType().FullName">@metadata.GetType().Name</span></td>
<td>@HtmlEncodeAndReplaceLineBreaks(metadata.ToString())</td>
Copy link
Member Author

Choose a reason for hiding this comment

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

I include both with HtmlEncodeAndReplaceLineBreaks and without in the description. I suggest to keep the one without. The razor would encode the html and omit the new lines.

@ghost ghost added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Dec 25, 2023
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment Feb 13, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 13, 2024
@wtgodbe wtgodbe removed the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 13, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 20, 2024
@danmoseley
Copy link
Member

Is next action here on us -- @JamesNK are you the right person to do the re-review?

@JamesNK
Copy link
Member

JamesNK commented Mar 7, 2024

Apologies for the delay in reviewing again. Looks good.

@JamesNK
Copy link
Member

JamesNK commented Mar 7, 2024

/azp run

@dotnet-policy-service dotnet-policy-service bot removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Mar 7, 2024
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@JamesNK JamesNK enabled auto-merge (squash) March 7, 2024 01:28
@JamesNK JamesNK merged commit 449abac into dotnet:main Mar 7, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-preview3 milestone Mar 7, 2024
@JamesNK JamesNK added the blog-candidate Consider mentioning this in the release blog post label Apr 2, 2024
Copy link
Contributor

@Kahbazi, this change will be considered for inclusion in the blog post for the release it'll ship in. Nice work!

Please ensure that the original comment in this thread contains a clear explanation of what the change does, why it's important (what problem does it solve?), and, if relevant, include things like code samples and/or performance numbers.

This content may not be exactly what goes into the blog post, but it will help the team putting together the announcement.

Thanks!

@Kahbazi Kahbazi deleted the kahbazi/MetadataOnDeveloperExceptionPage branch April 4, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares blog-candidate Consider mentioning this in the release blog post community-contribution Indicates that the PR has been added by a community member feature-diagnostics Diagnostic middleware and pages (except EF diagnostics)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add endpoint metadata to developer exception page
5 participants