/RequestLogs getting NotSupportedException

I am getting an exception trying to implement Request Logging. I can decorate the DTOs with RuntimeSerializable but I’d rather not there are many of of them and its not required for anything else at this point.

Config:

Plugins.Add(new RequestLogsFeature {
					RequestLogger = new RedisRequestLogger(container.Resolve<IRedisClientsManager>(), capacity:1000)
				});

DTO:

[Route("/user/reset","GET",Summary = @"Sends a reset link to user's email", 
	Notes = "")]
public class sendPasswordResetRequest
{
	public string UserEmail { get; set; }


}

Calling /requestlogs results in:

Read the release notes for different options.

I don’t understand the connection - the exception is being throw processing the request DTO which is not an Object, you are saying the response type of the service method is causing this?

That exception indicates it uses the Runtime object feature, what does sendPasswordResetRequest return? If nothing have it implement IReturnVoid otherwise specify the response Type with IReturn<T>.

MyService.Any(sendPasswordResetRequest req) returns an Object. We have a few of these object return types left over from early days trying to use SS caching…

changing these now and will see if it all works

Hmmm… have no objects on any DTOs now and still get it… albeit on a different service.

[Route("/Analytics/Stats/","GET",Summary = "Retrieves daily stats")]
    public class getStatsRequest
    {
    
    }



public DailyStatCollection Any(getStatsRequest req)
        {
...
}

 public class DailyStatCollection : BaseRecordRedis<DailyStatCollection>
    {
        public SortedDictionary<DateTime,DailyStat> stats { get; set; }
...

}

(BaseRecordRedis HAS NO PUBLIC OBJECT PROPERTIES OR FIELDS)

public class DailyStat
    {  
        public int OrderCnt { get; set; }
        public int ItemCnt { get; set; }
        public int ShipmentQtyCnt { get; set; }
        public int ShipmentRecvQtyCnt { get; set; }
        
    }

Error CodeNotSupportedExceptionMessagegetStatsRequest is not an allowed Runtime Type. Whitelist Type with [RuntimeSerializable] or IRuntimeSerializable.Stack Trace[RequestLogs: 07/28/2017 18:12:06]: [REQUEST: {Skip:0}] System.NotSupportedException: getStatsRequest is not an allowed Runtime Type. Whitelist Type with [RuntimeSerializable] or IRuntimeSerializable. at ServiceStack.Text.Common.JsWriter.AssertAllowedRuntimeType(Type type) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Common\JsWriter.cs:line 188 at ServiceStack.Text.Common.DeserializeType1.ExtractType(StringSegment strType) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Common\DeserializeType.cs:line 108 at ServiceStack.Text.Common.DeserializeType1.ObjectStringToType(StringSegment strType) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Common\DeserializeType.cs:line 52 at ServiceStack.Text.Common.TypeAccessor.<>c__DisplayClass6_0.b__0(StringSegment value) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Common\DeserializeType.cs:line 315 at ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(TypeConfig typeConfig, StringSegment strType, EmptyCtorDelegate ctorFn, Dictionary2 typeAccessorMap) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Common\DeserializeTypeRefJson.cs:line 201 at ServiceStack.Text.Json.JsonReader1.Parse(StringSegment value) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Json\JsonReader.Generic.cs:line 97 at ServiceStack.Text.Json.JsonReader1.Parse(String value) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\Json\JsonReader.Generic.cs:line 74 at ServiceStack.Text.JsonSerializer1.DeserializeFromString(String value) in C:\TeamCity\buildAgent\work\191dabb1a4b08b2c\src\ServiceStack.Text\JsonSerializer.Generic.cs:line 38 at ServiceStack.Redis.Generic.RedisTypedClient1.GetValues(List1 keys) in C:\TeamCity\buildAgent\work\6375db77c8028f43\src\ServiceStack.Redis\Generic\RedisTypedClient.cs:line 383 at ServiceStack.Host.RedisRequestLogger.GetLatestLogs(Nullable1 take) in C:\TeamCity\buildAgent\work\a61371dd01fad6bd\src\ServiceStack.Server\Host\RedisRequestLogger.cs:line 70 at ServiceStack.Admin.RequestLogsService.Any(RequestLogs request) in C:\TeamCity\buildAgent\work\a61371dd01fad6bd\src\ServiceStack\Admin\RequestLogsService.cs:line 90 at ServiceStack.Host.ServiceRunner1.Execute(IRequest request, Object instance, TRequest requestDto) in C:\TeamCity\buildAgent\work\a61371dd01fad6bd\src\ServiceStack\Host\ServiceRunner.cs:line 107

It’s the same error, start adding IReturnVoid, IReturn<T> on all your Request DTOs, a) it’s recommended b) it’s included in the Runtime Type white-list.

Wow ok that’s going to be a good chunk of work and I think 100% logically duplicative of defining the return DTO type of the service method… any chance to do this dynamically using reflection?

What, no that defeats the purpose of the Marker interfaces to decoratively annotate what your Services return and provide clients a Typed API.

You’ll need to choose from any of the other available solutions to whitelist your DTOs.

It does not defeat the purpose at all since I am defining the return type of the service method. The response type of a request DTO is totally implied. This need to define an interface for a request DTO is zero value add if the service methods already define the return type and you don’t attach more than one DTO to a service or vice versa. Crazy.

It absolutely defeats the purpose of the IReturn Marker interfaces which is to provide clients a Typed API to call your Services which can’t happen if the interfaces were added dynamically, which is impossible to do in .NET BTW.

If you’re going to specify the Response of your Services anywhere (which all Services should), it should be using the IReturn interface markers so that information is included as part of your typed Service contract and available to everyone.

We would appreciate the continued support of the non-interfaced request DTO use case as its obviously over my head why a developer would have to define the return type of their service method effectively as part of the parameter to the method itself.

I don’t understand how this sentence relates to IReturn<T> which just specifies what the Response Type of a Request DTO.

Can you try upgrading to the latest v4.5.13, as I’ve added RequestLogEntry type as a blessed type that can deserialize object properties.