Fix failing "build" CI job: ServerMetrics Reset action returns wrong response shape - #438
Conversation
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
… dotnet-tools.json change Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
| /// <param name="itemType">Item type for AddItem/RemoveItem/ListItems actions (e.g., 'Using', 'Content', 'None')</param> | ||
| /// <param name="include">The Include attribute value for AddItem/RemoveItem actions</param> | ||
| [McpServerTool(Title = ".NET Project", Destructive = true, TaskSupport = ToolTaskSupport.Optional, IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/File%20Folder/Flat/file_folder_flat.svg")] | ||
| [McpServerTool(Title = ".NET Project", Destructive = true, UseStructuredContent = true, OutputSchemaType = typeof(BuildResult), TaskSupport = ToolTaskSupport.Optional, IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/File%20Folder/Flat/file_folder_flat.svg")] |
| /// </summary> | ||
| /// <param name="action">The metrics operation to perform: Get (return current snapshot) or Reset (clear all counters)</param> | ||
| [McpServerTool(Title = "Server Metrics", ReadOnly = false, Idempotent = false, IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Bar%20Chart/Flat/bar_chart_flat.svg")] | ||
| [McpServerTool(Title = "Server Metrics", ReadOnly = false, Idempotent = false, UseStructuredContent = true, OutputSchemaType = typeof(ServerMetricsResponse), IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Bar%20Chart/Flat/bar_chart_flat.svg")] |
|
@copilot apply changes based on the comments in this thread |
…rics Reset returns ServerMetricsResponse Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
…ling) Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Applied both fixes (commit DotnetProject: Added DotnetServerMetrics: Reset now returns a All 7 |
…apshot Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Bug Fix
What was the bug?
The
DotnetServerMetricstool'sResetaction was returning aServerMetricsResponse(the same metrics snapshot shape used by theGetaction), which contains onlytoolMetrics,totalInvocations,totalSuccesses, andtotalFailuresfields. Two tests expected the Reset action to return a confirmation object withsuccess(bool) andmessage(string) properties, causing the CI build to fail.Failing tests:
DotnetServerMetrics_Reset_ClearsAllMetrics— asserted the response contained"reset"and"success"substringsDotnetServerMetrics_Reset_ReturnsSuccessJson— assertedsuccess: trueand a non-emptymessageproperty existed on the JSON rootHow did you fix it?
Added a new
ServerMetricsResetResponseclass withsuccessandmessageJSON properties, and updated theResetcase inDotNetCliTools.Metrics.csto return an instance of this class (success: true,message: "Server metrics have been reset.") instead of a metrics snapshot.Testing
ServerMetricsToolTeststests pass