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-993872: System.NullReferenceException when executing Command when CommandText is not set #838

Closed
felixtsem5 opened this issue Dec 18, 2023 · 4 comments
Assignees
Labels
enhancement The issue is a request for improvement or a new feature status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.

Comments

@felixtsem5
Copy link

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?

2.1.4

  1. What operating system and processor architecture are you using?

Any

  1. What version of .NET framework are you using?
    E.g. .net framework 4.5.2 or .net standard 2.0

.NET 6

  1. What did you do?

    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.

Exception below is thrown when trying to run an ExecuteNonQuery()/ExecuteScalar() on a SnowflakeDbCommand object with no CommandText.
System.NullReferenceException: 'Object reference not set to an instance of an object.'

  1. What did you expect to see?

    What should have happened and what happened instead?

Just state that CommandText is not there or empty.

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

    https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

    There is an example in READMD.md file showing you how to enable logging.

No, but I bet not checking the existence of the actual SQL in the TrimSql() method is why.

private string TrimSql(string originalSql)

Here's the partial stack trace:

at Snowflake.Data.Core.SFStatement.TrimSql(String originalSql)
at Snowflake.Data.Core.SFStatement.Execute(Int32 timeout, String sql, Dictionary`2 bindings, Boolean describeOnly)
at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteNonQuery()
[... My code after this]

  1. What is your Snowflake account identifier, if any? (Optional)
@felixtsem5 felixtsem5 added the bug label Dec 18, 2023
@github-actions github-actions bot changed the title System.NullReferenceException when executing Command when CommandText is not set SNOW-993872: System.NullReferenceException when executing Command when CommandText is not set Dec 18, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Dec 29, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage Issue is under initial triage and removed bug labels Dec 29, 2023
@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Dec 29, 2023

hi - thank you for submitting this issue. we'll take a look.

edit: indeed the issue is easily reproducible. We do document in the README.md that the CommandText is necessary to send the SQL query, but I agree that indeed the driver could be a bit smarter about the situation when it isn't set for any reason. We'll take care.

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature status-in_progress Issue is worked on by the driver team and removed status-triage Issue is under initial triage labels Jan 2, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added status-pr_pending_merge A PR is made and is under review and removed status-in_progress Issue is worked on by the driver team labels Feb 11, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR is made and is under review at #861

@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. enhancement The issue is a request for improvement or a new feature and removed enhancement The issue is a request for improvement or a new feature status-pr_pending_merge A PR is made and is under review labels Feb 14, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR is merged and will be part of the next driver release cycle, which is expected to happen around the second half of February

@sfc-gh-dszmolka
Copy link
Contributor

fix released with version 3.0.0, closing Issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is a request for improvement or a new feature status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.
Projects
None yet
Development

No branches or pull requests

3 participants