fix(scheduler): add [FromServices] to Doctor trend endpoint parameters
DoctorTrendEndpoints used IDoctorTrendRepository and TimeProvider as MapGet handler parameters without [FromServices], causing ASP.NET to infer them as body parameters — crashing the scheduler on startup with "Body was inferred but the method does not allow inferred body parameters." Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -219,8 +220,8 @@ public sealed class DoctorJobPlugin : ISchedulerJobPlugin
|
||||
DateTimeOffset? from,
|
||||
DateTimeOffset? to,
|
||||
HttpContext httpContext,
|
||||
IDoctorTrendRepository? trendRepository,
|
||||
TimeProvider timeProvider) =>
|
||||
[FromServices] IDoctorTrendRepository? trendRepository,
|
||||
[FromServices] TimeProvider timeProvider) =>
|
||||
{
|
||||
if (trendRepository is null)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using StellaOps.Scheduler.Plugin.Doctor.Services;
|
||||
|
||||
@@ -20,8 +21,8 @@ public static class DoctorTrendEndpoints
|
||||
group.MapGet("/", async (
|
||||
DateTimeOffset? from,
|
||||
DateTimeOffset? to,
|
||||
IDoctorTrendRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
[FromServices] IDoctorTrendRepository repository,
|
||||
[FromServices] TimeProvider timeProvider,
|
||||
HttpContext httpContext,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
@@ -46,8 +47,8 @@ public static class DoctorTrendEndpoints
|
||||
string checkId,
|
||||
DateTimeOffset? from,
|
||||
DateTimeOffset? to,
|
||||
IDoctorTrendRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
[FromServices] IDoctorTrendRepository repository,
|
||||
[FromServices] TimeProvider timeProvider,
|
||||
HttpContext httpContext,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
@@ -79,8 +80,8 @@ public static class DoctorTrendEndpoints
|
||||
string category,
|
||||
DateTimeOffset? from,
|
||||
DateTimeOffset? to,
|
||||
IDoctorTrendRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
[FromServices] IDoctorTrendRepository repository,
|
||||
[FromServices] TimeProvider timeProvider,
|
||||
HttpContext httpContext,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
@@ -111,8 +112,8 @@ public static class DoctorTrendEndpoints
|
||||
DateTimeOffset? from,
|
||||
DateTimeOffset? to,
|
||||
double? threshold,
|
||||
IDoctorTrendRepository repository,
|
||||
TimeProvider timeProvider,
|
||||
[FromServices] IDoctorTrendRepository repository,
|
||||
[FromServices] TimeProvider timeProvider,
|
||||
HttpContext httpContext,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user