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

[prerelease] panic with index out of range [1] when reading existing function #2490

Closed
sonya opened this issue Feb 12, 2024 · 1 comment · Fixed by #2456
Closed

[prerelease] panic with index out of range [1] when reading existing function #2490

sonya opened this issue Feb 12, 2024 · 1 comment · Fixed by #2456
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@sonya
Copy link
Contributor

sonya commented Feb 12, 2024

Terraform CLI and Provider Versions

Terraform v1.6.5
on darwin_arm64

Provider is built from current main branch (pre-0.86.0)

Terraform Configuration

I can reproduce the problem with just this

resource "snowflake_function" "my_function" {
  name            = "MY_FUNCTION"
  database        = "MY_DB"
  schema          = "MY_SCHEMA"
  return_type     = "VARCHAR"
  return_behavior = "IMMUTABLE"
  statement       = "SELECT PARAM"
  arguments {
    name = "PARAM"
    type = "VARCHAR"
  }
}

Expected Behavior

Based on the steps to reproduce, the last step should result in Your infrastructure matches the configuration.

Actual Behavior

terraform plan fails with the following stack trace:

Stack trace from the terraform-provider-snowflake plugin:

panic: runtime error: index out of range [1] with length 1

goroutine 3649 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewSchemaObjectIdentifierFromFullyQualifiedName({0x1400026c230?, 0x0?})
    ~/code/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/identifier_helpers.go:208 +0x344
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadContextFunction({0x1065eef50, 0x14000898770}, 0x1400150a780, {0x1065aad00?, 0x14000e85790?})
    ~/code/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/function.go:515 +0x1f4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000cb3260, {0x1065eeea8, 0x140006d6d20}, 0xd?, {0x1065aad00, 0x14000e85790})
    ~/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:795 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x14000cb3260, {0x1065eeea8, 0x140006d6d20}, 0x1400160eea0, {0x1065aad00, 0x14000e85790})
    ~/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1089 +0x430
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x14000cc84b0, {0x1065eeea8?, 0x140006d6bd0?}, 0x14000896b80)
    ~/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:663 +0x3e4
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x106604458?, 0x14000cc84b0?}}, {0x1065eeea8?, 0x140006d6bd0?}, 0x14000896a00?)
    ~/go/pkg/mod/github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:176 +0x228
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x1065eeee0?, {0x1065eeea8?, 0x140006d68d0?}, 0x14000896a00)
    ~/go/pkg/mod/github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:35 +0x184
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0x14000b34820, {0x1065eeea8?, 0x14000f17ec0?}, 0x1400108c300)
    ~/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:787 +0x390
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x106559360?, 0x14000b34820}, {0x1065eeea8, 0x14000f17ec0}, 0x1400150a500, 0x0)
    ~/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x164
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000ded20, {0x1065eeea8, 0x14000f17e30}, {0x1065ffa60, 0x140001036c0}, 0x14000dcac60, 0x14000d93710, 0x1073dbb88, 0x0)
    ~/go/pkg/mod/google.golang.org/[email protected]/server.go:1372 +0xb8c
google.golang.org/grpc.(*Server).handleStream(0x140000ded20, {0x1065ffa60, 0x140001036c0}, 0x14000dcac60)
    ~/go/pkg/mod/google.golang.org/[email protected]/server.go:1783 +0xc44
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    ~/go/pkg/mod/google.golang.org/[email protected]/server.go:1016 +0x5c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 43
    ~/go/pkg/mod/google.golang.org/[email protected]/server.go:1027 +0x138

Steps to Reproduce

  1. Install a currently released version of the provider (I started from 0.79.0)
  2. Deploy the above configuration to create a function
  3. Run terraform plan. You should see Your infrastructure matches the configuration..
  4. Install the 0.86.0 version of the provider (I built this off the current main branch)
  5. Run terraform plan.

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

I am filing this issue about a pre-release version so it isn't a real issue yet. I am flagging in the off-chance that it hasn't already been noticed and ends up being released.

@sonya sonya added the bug Used to mark issues with provider's incorrect behavior label Feb 12, 2024
@sonya sonya changed the title [prelease] panic with index out of range [1] when reading existing function [prerelease] panic with index out of range [1] when reading existing function Feb 13, 2024
sfc-gh-asawicki added a commit that referenced this issue Feb 15, 2024
- change parallel test in task
- run pre-push (because main was not pre-pushed: docs and reformat)
- fix materialized view datasource test
- add state upgrader to function resource's id
- add test utilizing older provider version

References: #2490
@sfc-gh-asawicki
Copy link
Collaborator

Hey @sonya. Thanks for bringing this to our attention.

I have fixed the behavior in #2503 by adding a state upgrader. We will release it today but you can check it prerelease if you want :)

sfc-gh-asawicki added a commit that referenced this issue Feb 15, 2024
- Removed incorrect validation on procedure resources that were causing
failure of the following tests:
  - `TestAcc_Procedure_Java`
  - `TestAcc_Procedure_Scala`
- Removed incorrect deprecation from table resource (#2488)
- Fixed ShowByID for views (#2506)
- Fixed notification_integration resource warnings for deprecated
parameters (#2501)
- Fixed external functions and procedure - state migrations similar to
functions (#2490)

References: #2501 #2506 #2488 #2490
sfc-gh-jcieslak pushed a commit that referenced this issue Feb 15, 2024
🤖 I have created a release *beep* *boop*
---


# Release notes
[0.86.0](v0.85.0...v0.86.0)
(2024-02-15)


## 🎉 **What's new**

* add refresh_mode and initialize to dynamic tables
([#2437](#2437))
([d301b20](d301b20))
* add resource snowflake_user_password_policy_attachment
([#2162](#2162))
([#2307](#2307))
([93af462](93af462))
* create a workaround for granting privileges on all pipes
([#2477](#2477))
([64f2346](64f2346))
* Handle IMPORTED PRIVILEGES privileges in privilege-to-role granting
resources
([#2471](#2471))
([eb20051](eb20051))
* use external functions
([#2454](#2454))
([417d473](417d473))
* use funcs from sdk
([#2462](#2462))
([a5f969c](a5f969c))
* use sdk for procedures
([#2450](#2450))
([94ac78a](94ac78a))
* Use sdk in table constraint resource
([#2466](#2466))
([d685603](d685603))
* Use tables from SDK
([#2453](#2453))
([fdb4f88](fdb4f88))


## 🔧 **Misc**

* Add migration notes to the docs and change jira integration
([#2497](#2497))
([b17f1af](b17f1af))
* Change email and issue reporter
([#2470](#2470))
([5865655](5865655))
* Grants migration guide
([#2455](#2455))
([62c70fd](62c70fd))
* Remove unused old implementation from snowflake pkg
([#2458](#2458))
([2d0e508](2d0e508))
* update password policy attachment
([#2485](#2485))
([6ec9ff7](6ec9ff7))


## 🐛 **Bug fixes**

* allow DT warehouse to be updated in-place
([#2439](#2439))
([d565af1](d565af1))
* correct test dependencies
([#2493](#2493))
([dfb247f](dfb247f))
* FileFormat not detecting changes correctly
([#2436](#2436))
([018bb74](018bb74))
* Fix few smaller issues
([#2507](#2507))
([a836871](a836871))
* Fix functions and small other fixes
([#2503](#2503))
([0d4aba4](0d4aba4)),
closes
[#2490](#2490)
* Fix tag tests in view and in materialized view
([#2457](#2457))
([2de942a](2de942a))
* Fix task related issues
([#2479](#2479))
([0385650](0385650))
* Fix tests that base on default data retention
([#2465](#2465))
([682e28c](682e28c))
* grant privileges to share test terraform dependencies
([#2473](#2473))
([ede8d95](ede8d95))
* parameter issues
([#2463](#2463))
([7ee4986](7ee4986))
* parse dynamic table query from DDL
([#2438](#2438))
([d76815c](d76815c))
* Remove title and body temporarily from jira integration
([#2499](#2499))
([672c97d](672c97d))
* SHOW GRANTS mapping for share data type
([#2508](#2508))
([feb4d44](feb4d44))
* user error handling
([#2486](#2486))
([dfa52b2](dfa52b2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants