How to fix System.NullReferenceException for Static Web Apps using Data API Builder?
Aryan Misra
0
Reputation points
I've been developing a Static Web App in Next.js with Data API Builder to interface with an Azure SQL database. Local development using the Azure CLI has been working for the past couple months but in the last week it has stopped working and I'm met with this error:
[dataApi] Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
[dataApi] at Azure.DataApiBuilder.Config.Converters.EntitySourceConverterFactory.EntitySourceConverter.<>c.<Read>b__2_2(KeyValuePair`2 p) in /_/src/Config/Converters/EntitySourceConverterFactory.cs:line 67
[dataApi] at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
[dataApi] at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
[dataApi] at Azure.DataApiBuilder.Config.Converters.EntitySourceConverterFactory.EntitySourceConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/Config/Converters/EntitySourceConverterFactory.cs:line 67
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state, Object& value)
[dataApi] at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
[dataApi] at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonDictionaryConverter`3.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TDictionary& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
[dataApi] at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
[dataApi] at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
[dataApi] at System.Text.Json.JsonSerializer.Deserialize[TValue](Utf8JsonReader& reader, JsonSerializerOptions options)
[dataApi] at Azure.DataApiBuilder.Config.Converters.RuntimeEntitiesConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/Config/Converters/RuntimeEntitiesConverter.cs:line 16
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.TryRead[TArg](ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo, TArg& arg)
[dataApi] at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
[dataApi] at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
[dataApi] at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
[dataApi] at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
[dataApi] at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
[dataApi] at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
[dataApi] at Azure.DataApiBuilder.Config.RuntimeConfigLoader.TryParseConfig(String json, RuntimeConfig& config, ILogger logger, String connectionString, Boolean replaceEnvVar) in /_/src/Config/RuntimeConfigLoader.cs:line 56
[dataApi] at Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader.TryLoadConfig(String path, RuntimeConfig& config, Boolean replaceEnvVar) in /_/src/Config/FileSystemRuntimeConfigLoader.cs:line 78
[dataApi] at Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader.TryLoadKnownConfig(RuntimeConfig& config, Boolean replaceEnvVar) in /_/src/Config/FileSystemRuntimeConfigLoader.cs:line 101
[dataApi] at Cli.ConfigGenerator.TryStartEngineWithOptions(StartOptions options, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem) in /_/src/Cli/ConfigGenerator.cs:line 972
[dataApi] at Cli.Commands.StartOptions.Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem) in /_/src/Cli/Commands/StartOptions.cs:line 41
[dataApi] at Cli.Program.<>c__DisplayClass2_0.<Execute>b__4(StartOptions options) in /_/src/Cli/Program.cs:line 60
[dataApi] at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
[dataApi] at Cli.Program.Execute(String[] args, ILogger cliLogger, IFileSystem fileSystem, FileSystemRuntimeConfigLoader loader) in /_/src/Cli/Program.cs:line 56
[dataApi] at Cli.Program.Main(String[] args) in /_/src/Cli/Program.cs:line 41
[dataApi] /bin/sh: line 1: 86090 Abort trap: 6 "/Users/aryan/.swa/dataApiBuilder/0.8.49/Microsoft.DataApiBuilder" start -c staticwebapp.database.config.json --no-https-redirect
[dataApi] cd "/Users/aryan/Code/eeco-databaser-ui/swa-db-connections" && "/Users/aryan/.swa/dataApiBuilder/0.8.49/Microsoft.DataApiBuilder" start -c staticwebapp.database.config.json --no-https-redirect exited with code 134
--> Sending SIGTERM to other processes..
[swa] node "/Users/aryan/.nvm/versions/node/v20.5.1/lib/node_modules/@azure/static-web-apps-cli/dist/msha/server.js" exited with code 0
--> Sending SIGTERM to other processes..
[run] cd "/Users/aryan/Code/eeco-databaser-ui" && npm run dev exited with code SIGTERM
✖ SWA emulator stoped because the --run command exited with code SIGTERM.
I'm running it with the following command:
swa start --data-api-location swa-db-connections
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,175 questions
Sign in to answer