Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1805438: BuildResultSet >> NullReferenceException #1059

Open
GSerjo opened this issue Nov 14, 2024 · 2 comments
Open

SNOW-1805438: BuildResultSet >> NullReferenceException #1059

GSerjo opened this issue Nov 14, 2024 · 2 comments
Assignees
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@GSerjo
Copy link

GSerjo commented Nov 14, 2024

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of .NET driver are you using?
    <PackageReference Include="Snowflake.Data" Version="4.2.0" />

  2. What operating system and processor architecture are you using?
    windows x64

  3. What version of .NET framework are you using?
    net8.0

  4. What did you do?
    called ExecuteNonQueryAsync(cancellationToken); on DbCommand

  5. What did you expect to see?
    Descriptive error message: what was wrong. The current driver's implementation throws a null reference exception.

  6. Can you set logging to DEBUG and collect the logs?

here's call stack

System.NullReferenceException: Object reference not set to an instance of an object.
   at Snowflake.Data.Core.SFStatement.BuildResultSet(QueryExecResponse response, CancellationToken cancellationToken)
   at Snowflake.Data.Core.SFStatement.GetResultWithId(String resultId)
   at Snowflake.Data.Core.SFMultiStatementsResultSet.NextResult()
   at Snowflake.Data.Core.SFMultiStatementsResultSet..ctor(QueryExecResponseData responseData, SFStatement sfStatement, CancellationToken cancellationToken)
   at Snowflake.Data.Core.SFStatement.BuildResultSet(QueryExecResponse response, CancellationToken cancellationToken)
   at Snowflake.Data.Core.SFStatement.ExecuteAsync(Int32 timeout, String sql, Dictionary`2 bindings, Boolean describeOnly, Boolean asyncExec, CancellationToken cancellationToken)
   at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)

Looks like the response is null somehow

private SFBaseResultSet BuildResultSet(
      QueryExecResponse response,
      CancellationToken cancellationToken)
    {
      if (response.data != null && response.data.queryId != null)
        this._lastQueryId = response.data.queryId;
      if (!response.success)
        throw new SnowflakeDbException(response.data.sqlState, response.code, response.message, response.data.queryId);
      if (response.data.resultIds != null && response.data.resultIds.Length > 0)
        return (SFBaseResultSet) new SFMultiStatementsResultSet(response.data, this, cancellationToken);
      return response.data.queryResultFormat == ResultFormat.ARROW ? (SFBaseResultSet) new ArrowResultSet(response.data, this, cancellationToken) : (SFBaseResultSet) new SFResultSet(response.data, this, cancellationToken);
    }

Based on the call stack, here's what has been called before the exception

public T Get<T>(IRestRequest request)
    {
      return Task.Run<T>((Func<Task<T>>) (async () => await this.GetAsync<T>(request, CancellationToken.None).ConfigureAwait(false))).Result;
    }

    public async Task<T> GetAsync<T>(IRestRequest request, CancellationToken cancellationToken)
    {
      T async;
      using (HttpResponseMessage response = await this.GetAsync(request, cancellationToken).ConfigureAwait(false))
        async = JsonConvert.DeserializeObject<T>(await response.Content.ReadAsStringAsync().ConfigureAwait(false), JsonUtils.JsonSettings);
      return async;
    }

Don't know the exact command's query params. It would be nice if the connector will catch the exception and provide some details on what was wrong.

@GSerjo GSerjo added the bug label Nov 14, 2024
@github-actions github-actions bot changed the title BuildResultSet >> NullReferenceException SNOW-1805438: BuildResultSet >> NullReferenceException Nov 14, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Nov 15, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi - thanks for reporting this issue and the analysis ! we'll take a look

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-pr_pending_merge A PR is made and is under review label Nov 18, 2024
@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Nov 18, 2024

fix in review: #1061
edit: PR is already merged; thus will be part of the next driver release

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-pr_pending_merge A PR is made and is under review labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants