Dart Generator returns `Invalid Response`

I try to execute x dart http://bsc-linuxdev:13666 and I get the following error:

Invalid Response from http://bsc-linuxdev:13666/types/dart

In the log of my server I see the following entries:

2021-09-09 10:25:51.517 +02:00 [DBG] [] [ThreadId: 29]  null ClientRestCall  () null Request stats: TypesDart | /types/dart | bsc-linuxdev:13666 | 10.66.66.1 |  
2021-09-09 10:25:51.518 +02:00 [ERR] [] [ThreadId: 29]  null ClientRestCall  () null Uncaught Exception: ArgumentNullException: Value cannot be null. (Parameter 's') | Det. Value cannot be null. (Parameter 's')

Do I miss something? Any idea where I can get further details or what might be wrong here?

UPDATE
I was just watching your video regarding Dart and there you say .NET 5 is requied. My servers run on .NETCore 3.1 as docker containers. May this cause the problem??

I also tried the Android Studio Plugin. There I get a different strange error message:

The URL is valid. In the browser it returns the metadata page Listing all my APIs

Can’t tell what the issue is without a repro or full error details.

What’s the complete HTTP Response of your Dart DTOs route?

http://bsc-linuxdev:13666/types/dart

Hi @mythz
Found it, fully my fault, sorry for making noise here…
Some time ago I added a GlobalRequestFilter which writes some statistic data to a database. It was assuming that the session is authenticatd and ended in a NPE when I did int.Parse(session.UserAuthId). If the session is not authenticated Session.UserAuthId is of course NULL which caused the above described error…

But this leads me to another question:
How can I disable this in production? I was just reading through Restricting services but I currently don’t see how I can deny all those x tools code generators ?

And regarding NPE: I saw an other problem with the generated Dart code: It seems NOT support NULL safety. That was a breaking change introduced with Dart SDK 2.12. I know that I can set the SDK version in my pubspec.yaml file to 2.11, but that may have other impacts. The current Dart SDK version is 2.14.1.

UPDATE
Ohh, just read this. I am still on 5.11 and will quickly update to 5.12, assuming it is built in there (NuGet and not MyGet).

1 Like

I’ve no idea what this is asking.

Yep it is, your Flutter/Dart Apps will also need to update to use the latest servicestack v2.0.0 library:

dependencies:
  servicestack: ^2.0.0

NativeTypes is a feature plugin which can be removed for production if you only do your client code generation locally or in lower environments.

if (HostingEnvironment.IsProduction())
{
    Plugins.RemoveAll(x => x is NativeTypesFeature);
}

Or you can disable using SetConfig and EnableFeatures and the Metadata feature, eg

var hostConfig = new HostConfig
{
    DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), HostingEnvironment.IsDevelopment())
};

if (HostingEnvironment.IsProduction())
{
    hostConfig.EnableFeatures = Feature.All.Remove(Feature.Metadata);
}

SetConfig(hostConfig);

Hi @layoric
Thanks a lot, exactly what I was looking for. I just searched in the wrong area (was not aware of the fact this is a plugin…).