Search code examples
servicestackservicestack-autoquery

ServiceStack AutoQuery warning about missing property


When I query an AutoQuery service (regular GET request), I get a warning in the log, even if the request works fine. The warning looks like this, for URL: https://localhost:5001/employees?BirthDate%3E=1950-01-01

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://localhost:5001/employees?BirthDate%3E=1950-01-01 - -
warn: ServiceStack.Serialization.StringMapTypeDeserializer[0]
      Property 'birthdate>' does not exist on type 'autoquery.ServiceModel.AutoQueries+QueryEmployee'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 GET https://localhost:5001/employees?BirthDate%3E=1950-01-01 - - - 200 - text/html 291.5297ms

I've created an example, using the Northwind database, which I got with x mix northwind.sqlite and DTO from the official sample here: https://github.com/ServiceStackApps/Northwind/blob/master/src/Northwind/Northwind.ServiceModel/Types/Employee.cs.

This "false warnings" are a bit troublesome, as there is nothing wrong, and it fills up my logs with warnings that I need to ignore. Especially since I've setup alarms for WARN+ERR in the log.

I working sample here: https://github.com/specimen151/autoquerywarning


Solution

  • This is expected when using AutoQuery's Implicit Contentions where a warning is logged because a request is sent to an API without a matching Request DTO property.

    You can either add BirthDate as a typed property of the AutoQuery DTO, or you can ignore all "BirthDate" properties with:

    SetConfig(new HostConfig {
        IgnoreWarningsOnPropertyNames = { "BirthDate" }
    });
    

    Or you can disable all missing property warnings with:

    SetConfig(new HostConfig {
        IgnoreWarningsOnAllProperties = true
    });
    

    In the latest v5.12.1 that's now available on MyGet ServiceStack will no longer warn about missing properties on AutoQuery DTOs by default, it can be re-enabled with:

    SetConfig(new HostConfig {
        IgnoreWarningsOnAutoQueryApis = false
    });