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

[Bug]: nil pointer dereference error in dms.checkDefaultValues #36588

Open
jquag opened this issue Mar 26, 2024 · 5 comments
Open

[Bug]: nil pointer dereference error in dms.checkDefaultValues #36588

jquag opened this issue Mar 26, 2024 · 5 comments
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/dms Issues and PRs that pertain to the dms service.

Comments

@jquag
Copy link

jquag commented Mar 26, 2024

Terraform Core Version

1.5.1

AWS Provider Version

5.42.0

Affected Resource(s)

aws_dms_replication_task

Expected Behavior

I expect the aws_dms_replication_task resource to be created successfully the first time as well as being updated successfully on subsequent changes.

Actual Behavior

The resource is created successfully but fails on any updates.

Relevant Error/Panic Output Snippet

Stack trace from the terraform-provider-aws_v5.42.0_x5 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0xc7abdd9]
goroutine 1029 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/dms.checkdefaultvalues(0xc00287d000?, 0xe9b?)
                github.com/hashicorp/terraform-provider-aws/internal/service/dms/task_settings_json.go:233 +0x119
github.com/hashicorp/terraform-provider-aws/internal/service/dms.normalizeTaskSettings({0xc002843000, 0xe9b})
                github.com/hashicorp/terraform-provider-aws/internal/service/dms/task_settings_json.go:210 +0x2ae5
github.com/hashicorp/terraform-provider-aws/internal/service/dms.suppressEquivalentTaskSettings({0x4185c8?, 0x115f136e?}, {0xc002843000, 0xe9b}, {0xc002850160, 0x157}, 0xc004d5bf80?)
                github.com/hashicorp/terraform-provider-aws/internal/service/dms/task_settings_json.go:225 +0xba
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diff(0x6?, {0x12f7d928, 0xc002838690}, {0x115f136e, 0x19}, 0xc000e75040, 0xc004d5bf00, {0x12fa44e0?, 0xc004d5bf80}, 0x0)
                github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/schema.go:1143 +0x392
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0xc00100db00, {0x12f7d928, 0xc002838690}, 0xc002008d00, 0xc002582e10, 0xc0000113c8, {0x114b87a0, 0xc002563180}, 0x0)
                github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/schema.go:678 +0x332
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x12f7dd20?, {0x12f7d928?, 0xc002838690?}, 0xc002008d00, 0xf776ca0?, {0x114b87a0?, 0xc002563180?})
                github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:962 +0xd5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0xc001e173e0, {0x12f7d928?, 0xc002838570?}, 0xc002582960)
                github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:798 +0x9b6
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).PlanResourceChange(0xc00116b9d0, {0x12f7d928?, 0xc002838270?}, 0xc002582960)
                github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf5muxserver/mux_server_PlanResourceChange.go:73 +0x2ad
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0xc000a9a0a0, {0x12f7d928?, 0xc0025b9a40?}, 0xc00248f490)
                github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:811 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x11261960?, 0xc000a9a0a0}, {0x12f7d928, 0xc0025b9a40}, 0xc00461fe00, 0x0)
                github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:500 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc001642200, {0x12f7d928, 0xc0028de6f0}, {0x12fb6938, 0xc002686680}, 0xc002751c20, 0xc0026143c0, 0x1b175a60, 0x0)
                google.golang.org/grpc@v1.62.0/server.go:1383 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc001642200, {0x12fb6938, 0xc002686680}, 0xc002751c20)
                google.golang.org/grpc@v1.62.0/server.go:1794 +0x100c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
                google.golang.org/grpc@v1.62.0/server.go:1027 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 45
                google.golang.org/grpc@v1.62.0/server.go:1038 +0x135
Error: The terraform-provider-aws_v5.42.0_x5 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Terraform Configuration Files

Sorry, I can't provide a full set of configuration files for this issue but I believe the key is having BeforeImageSettings defined in the aws_dms_replication_task resource as below...

resource "aws_dms_replication_task" "postgres_replication_task" {
  migration_type           = "cdc"
  table_mappings           = file("${path.module}/dms_table_mappings.json")
  replication_task_id      = "my-replication-task"
  replication_instance_arn = aws_dms_replication_instance.postgres_replication_instance.replication_instance_arn
  source_endpoint_arn      = aws_dms_endpoint.source_endpoint.endpoint_arn
  target_endpoint_arn      = aws_dms_endpoint.target_endpoint.endpoint_arn
  start_replication_task   = true
 
  replication_task_settings = jsonencode({
    "BeforeImageSettings": {
      "EnableBeforeImage": true,
      "ColumnFilter": "all",
      "FieldName": "previous-value"
    },
    "FullLoadSettings": {
      "TargetTablePrepMode": "DO_NOTHING",
      "CreatePkAfterFullLoad": false,
      "StopTaskCachedChangesApplied": false,
      "StopTaskCachedChangesNotApplied": false,
      "MaxFullLoadSubTasks": 30,
      "TransactionConsistencyTimeout": 600,
      "CommitRate": 10000
    },
  })
}

Steps to Reproduce

Apply the terraform including an aws_dms_replication_task similar to the provided.
The first apply should succeed.
Apply the terraform a second time and you should see the error.

Debug Output

No response

Panic Output

No response

Important Factoids

Based on what I see in the source code where the panic is happening (github.com/hashicorp/terraform-provider-aws/internal/service/dms/task_settings_json.go:233), it looks like it is not expected that a value from defaultMap would be nil. However, as can be seen on line 48, the defaultSettings map is created with a value of nil for the key "BeforeImageSettings".

I suspect this causes the panic if ever the aws_dms_replication_task includes "BeforeImageSettings".

References

No response

Would you like to implement a fix?

None

@jquag jquag added the bug Addresses a defect in current functionality. label Mar 26, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added crash Results from or addresses a Terraform crash or kernel panic. service/dms Issues and PRs that pertain to the dms service. labels Mar 26, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 26, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Mar 26, 2024
@jquag jquag changed the title [Bug]: nil pointer derefernce error in dms.checkDefaultValues [Bug]: nil pointer dereference error in dms.checkDefaultValues Mar 26, 2024
@shmathes
Copy link

I ran into a similar issue today. In my task setting, I had null values for items we didn't need. After hitting the nil pointer panic, did like jquag and looked at task_settings_json.go and any key that was assigned with nil, I removed from my settings and after that it worked like a charm.

@ponkio-o
Copy link
Contributor

I'm facing the same issue now. It happened when I updated the terraform-provider-aws v5.42.0.

@nijave
Copy link
Contributor

nijave commented Apr 9, 2024

Seeing this as well. I assume related to recent changes here #36035 cc @nam054

@ponkio-o
Copy link
Contributor

ponkio-o commented May 4, 2024

Was this issue solved by #36967 ?
Actually, terraform plan executed successfully in my environment using v5.48.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/dms Issues and PRs that pertain to the dms service.
Projects
None yet
Development

No branches or pull requests

5 participants