Skip to content

[Bug]: missing OTEL environment variables in multi-config fails. #3271

@JerryNixon

Description

@JerryNixon

What?

When multi-config scenario, when the second config's runtime has telemetry values set from environment variables that do not exist in the environment.

This is an @env() error, perhaps we should assume @akv() is also affected by this?

Details

This is a snippet of the master configuration in a multi-config scenario.

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/vmajor.minor.patch/dab.draft.schema.json",
  "data-source": {
    "database-type": "mssql",
    "connection-string": "@env('MSSQL_CONNECTION_STRING')",
    "options": {
      "set-session-context": false
    }
  },
  "data-source-files": [ "dab-config-2.json" ],

This is a snippet of the second configuration file:

    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')",
        "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')",
        "service-name": "@env('OTEL_SERVICE_NAME')"
      }
    },

Then, dab start throws an exception, which it should not do in ANY circumstance, especially runtime in a child configuration file:

Deserialization of the configuration file failed during a post-processing step.
Message:
 Environmental Variable, OTEL_EXPORTER_OTLP_ENDPOINT, not found.
Stack Trace:
    at Azure.DataApiBuilder.Config.DeserializationVariableReplacementSettings.ReplaceEnvVariable(Match match) in /_/src/Config/DeserializationVariableReplacementSettings.cs:line 143
   at System.Text.RegularExpressions.Regex.<>c.<Replace>b__99_0(ValueTuple`5& state, Match match)
   at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[TState](String inputString, ReadOnlySpan`1 inputSpan, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject)
   at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[TState](String input, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject)
   at System.Text.RegularExpressions.Regex.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
   at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
   at Azure.DataApiBuilder.Config.Converters.StringJsonConverterFactory.StringJsonConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/Config/Converters/StringJsonConverterFactory.cs:line 55
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, Object& value)

And then, surprisingly, it still starts DAB with ONLY the first configuration.

Important

Exceptions during start should halt all startup

However

When you dab start the second config file directly, it starts without the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.0configchanges related to config

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions