Skip to content

NullReferenceException with request parameters #126

@NickDarvey

Description

@NickDarvey

Description

I'm getting a NullReferenceException while constructing a request to the Slack API using their Swagger definition.

I'm unfamiliar with Type Providers so I'm not sure how to approach debugging it. Right now I'm poking through decompiled IL (see below).

Repro steps

See this test.

Expected behavior

Constructs a request and sends it (at which point it should get a authorization error).

Actual behavior

[21:02:51 ERR] All/TP Slack Tests/call provided methods errored in 00:00:00.0360000 <Expecto>
System.NullReferenceException: Object reference not set to an instance of an object.
   at Swagger.Slack.Tests.Slack.Client.ChatPostEphemeral(Nullable`1 threadTs, String blocks, String attachments, Nullable`1 asUser, String parse, String token, String text, String user, Nullable`1 linkNames, String channel)
   at Swagger.Slack.Tests.slackTests@16.Invoke(Unit unitVar)

Known workarounds

None.

Related information

  • Branch: dev

Decompiled IL of ChatPostEphemeral method

public FSharpAsync ChatPostEphemeral([DefaultParameterValue(null)] [Optional] FSharpOption threadTs = default(FSharpOption), [DefaultParameterValue(null)] [Optional] string blocks = null, [DefaultParameterValue(null)] [Optional] string attachments = null, [DefaultParameterValue(null)] [Optional] FSharpOption asUser = default(FSharpOption), [DefaultParameterValue(null)] [Optional] string parse = null, [DefaultParameterValue(null)] [Optional] string token = null, [DefaultParameterValue(null)] [Optional] string text = null, [DefaultParameterValue(null)] [Optional] string user = null, [DefaultParameterValue(null)] [Optional] FSharpOption linkNames = default(FSharpOption), [DefaultParameterValue(null)] [Optional] string channel = null)
{
    //IL_0014: Unknown result type (might be due to invalid IL or missing references)
    //IL_001b: Unknown result type (might be due to invalid IL or missing references)
    //IL_001c: Unknown result type (might be due to invalid IL or missing references)
    //IL_0026: Unknown result type (might be due to invalid IL or missing references)
    //IL_0027: Expected O, but got Unknown
    //IL_0036: Unknown result type (might be due to invalid IL or missing references)
    //IL_003b: Unknown result type (might be due to invalid IL or missing references)
    //IL_0040: Expected O, but got Unknown
    //IL_005f: Unknown result type (might be due to invalid IL or missing references)
    //IL_0064: Unknown result type (might be due to invalid IL or missing references)
    //IL_0069: Expected O, but got Unknown
    //IL_0088: Unknown result type (might be due to invalid IL or missing references)
    //IL_008d: Unknown result type (might be due to invalid IL or missing references)
    //IL_0092: Expected O, but got Unknown
    //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
    //IL_00a3: Expected O, but got Unknown
    //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
    //IL_00b7: Unknown result type (might be due to invalid IL or missing references)
    //IL_00bc: Expected O, but got Unknown
    //IL_00dc: Unknown result type (might be due to invalid IL or missing references)
    //IL_00e1: Unknown result type (might be due to invalid IL or missing references)
    //IL_00e6: Expected O, but got Unknown
    //IL_0106: Unknown result type (might be due to invalid IL or missing references)
    //IL_010b: Unknown result type (might be due to invalid IL or missing references)
    //IL_0110: Expected O, but got Unknown
    //IL_0130: Unknown result type (might be due to invalid IL or missing references)
    //IL_0135: Unknown result type (might be due to invalid IL or missing references)
    //IL_013a: Expected O, but got Unknown
    //IL_0149: Unknown result type (might be due to invalid IL or missing references)
    //IL_014b: Expected O, but got Unknown
    //IL_015a: Unknown result type (might be due to invalid IL or missing references)
    //IL_015f: Unknown result type (might be due to invalid IL or missing references)
    //IL_0164: Expected O, but got Unknown
    //IL_0184: Unknown result type (might be due to invalid IL or missing references)
    //IL_0189: Unknown result type (might be due to invalid IL or missing references)
    //IL_018e: Expected O, but got Unknown
    //IL_01cc: Unknown result type (might be due to invalid IL or missing references)
    //IL_01d4: Unknown result type (might be due to invalid IL or missing references)
    //IL_01d6: Unknown result type (might be due to invalid IL or missing references)
    //IL_01db: Unknown result type (might be due to invalid IL or missing references)
    //IL_01e0: Expected O, but got Unknown
    //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
    //IL_02db: Unknown result type (might be due to invalid IL or missing references)
    //IL_02e0: Unknown result type (might be due to invalid IL or missing references)
    //IL_02ee: Unknown result type (might be due to invalid IL or missing references)
    //IL_02ef: Unknown result type (might be due to invalid IL or missing references)
    //IL_02f4: Unknown result type (might be due to invalid IL or missing references)
    //IL_02f9: Expected O, but got Unknown
    //IL_0303: Unknown result type (might be due to invalid IL or missing references)
    Type obj = typeof(FSharpMap);
    FSharpFunc mapping = new Lambda40e03960-767e-479d-9bc5-59dcf2b14dc6();
    IEnumerable<KeyValuePair<string, string>> nameValueCollection = (IEnumerable<KeyValuePair<string, string>>)new Lambda133ea8de-40e5-49fe-a698-cd8882350d21
    {
        mapping = mapping
    }.Invoke((!0)SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(SeqModule.Append<Tuple<string, string>>(Operators.CreateSequence<Tuple<string, string>>((IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("thread_ts", ((object)threadTs).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("blocks", ((object)blocks).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("attachments", ((object)attachments).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("as_user", ((object)asUser).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("parse", ((object)parse).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("text", ((object)text).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("user", ((object)user).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("link_names", ((object)linkNames).ToString()), FSharpList.get_Empty())), (IEnumerable<Tuple<string, string>>)FSharpList.Cons((!0)new Tuple<string, string>("channel", ((object)channel).ToString()), FSharpList.get_Empty())));
    string uri = RuntimeHelpers.combineUrl("http://fake-host/", RuntimeHelpers.combineUrl("/api", "/chat.postEphemeral"));
    UriBuilder uriBuilder = new UriBuilder(uri);
    Lambda8df8c1b2-2dcc-4850-88fd-5bd49e0efc14 lambda8df8c1b2-2dcc-4850-88fd-5bd49e0efc = new Lambda8df8c1b2-2dcc-4850-88fd-5bd49e0efc14();
    FSharpFunc mapping2 = new Lambda1713dcb0-a6d1-4fe4-8f00-9b1312711f3a();
    string text2 = (string)lambda8df8c1b2-2dcc-4850-88fd-5bd49e0efc.Invoke((!0)new Lambdaa3d9630b-db31-40c0-99c7-d96b0dd770fb
    {
        mapping = mapping2
    }.Invoke((!0)FSharpList.get_Empty()));
    if (string.IsNullOrEmpty(uriBuilder.Query))
    {
        uriBuilder.Query = text2;
    }
    else
    {
        uriBuilder.Query = string.Format("{0}&{1}", (object)uriBuilder.Query, (object)text2);
    }
    string uriString = uriBuilder.Uri.ToString().Substring("http://fake-host/".Length);
    HttpMethod method = new HttpMethod("POST");
    HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, new Uri(uriString, UriKind.Relative))
    {
        Content = (HttpContent)new FormUrlEncodedContent(nameValueCollection)
    };
    RuntimeHelpers.fillHeaders(httpRequestMessage, (IEnumerable<Tuple<string, string>>)ArrayModule.Append<Tuple<string, string>>((1 == 0) ? new Tuple<string, string>[0] : new Tuple<string, string>[1]
    {
        new Tuple<string, string>("Content-Type", "application/json")
    }, new Tuple<string, string>[1]
    {
        new Tuple<string, string>("token", ((object)token).ToString())
    }));
    FSharpAsync x = this.CallAsync(httpRequestMessage);
    return RuntimeHelpers.asyncCast(obj, new Lambda2812a87e-1602-4572-8f53-405ee1f7458c
    {
        @this = this,
        x = x
    }.Invoke((!0)ExtraTopLevelOperators.get_DefaultAsyncBuilder()));
}

Though I'm not sure how useful this is as even though I've added the DLLs to ILSpy I'm getting...

// SwaggerProvider.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
	// Assembly reference loading information:
	// There were some problems during assembly reference load, see below for more information!
	// Error: Could not find reference: SwaggerProvider.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
	// Info: Success - Found in Assembly List

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions