From 851e9c12109fa191092a9e83800c01f070a0e412 Mon Sep 17 00:00:00 2001
From: Thomas Kappler <tkappler@pulumi.com>
Date: Fri, 31 May 2024 15:42:28 +0200
Subject: [PATCH] Fix staticcheck warnings

---
 infer/provider.go      | 6 +++---
 infer/resource.go      | 4 ++--
 infer/resource_test.go | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/infer/provider.go b/infer/provider.go
index 32cafdc..dfe80f0 100644
--- a/infer/provider.go
+++ b/infer/provider.go
@@ -80,19 +80,19 @@ func (o Options) dispatch() dispatch.Options {
 	functions := map[tokens.Type]t.Invoke{}
 	for _, r := range o.Functions {
 		typ, err := r.GetToken()
-		contract.AssertNoError(err)
+		contract.AssertNoErrorf(err, "failed to get token for function %v", r)
 		functions[typ] = r
 	}
 	customs := map[tokens.Type]t.CustomResource{}
 	for _, r := range o.Resources {
 		typ, err := r.GetToken()
-		contract.AssertNoError(err)
+		contract.AssertNoErrorf(err, "failed to get token for resource %v", r)
 		customs[typ] = r
 	}
 	components := map[tokens.Type]t.ComponentResource{}
 	for _, r := range o.Components {
 		typ, err := r.GetToken()
-		contract.AssertNoError(err)
+		contract.AssertNoErrorf(err, "failed to get token for component %v", r)
 		components[typ] = r
 	}
 	return dispatch.Options{
diff --git a/infer/resource.go b/infer/resource.go
index f9c99e7..f5890a5 100644
--- a/infer/resource.go
+++ b/infer/resource.go
@@ -646,11 +646,11 @@ func (g *fieldGenerator) ensureDefaultSecrets() {
 
 	args, ok, err := g.argsMatcher.TargetStructFields(g.args)
 	contract.Assertf(ok, "we match by construction")
-	contract.AssertNoError(err)
+	contract.AssertNoErrorf(err, "TargetStructFields on %v", g.args)
 
 	state, ok, err := g.stateMatcher.TargetStructFields(g.state)
 	contract.Assertf(ok, "we match by construction")
-	contract.AssertNoError(err)
+	contract.AssertNoErrorf(err, "TargetStructFields on %v", g.state)
 
 	for _, f := range state {
 		if f.Internal {
diff --git a/infer/resource_test.go b/infer/resource_test.go
index 639703c..41c408f 100644
--- a/infer/resource_test.go
+++ b/infer/resource_test.go
@@ -336,9 +336,10 @@ func testHydrateFromState[O any](
 	return func(t *testing.T) {
 		t.Parallel()
 
+		type contextKey string
 		ctx := testContext{
 			//nolint:revive
-			Context: context.WithValue(context.Background(), "migrations", migrations),
+			Context: context.WithValue(context.Background(), contextKey("migrations"), migrations),
 		}
 
 		enc, actual, err := hydrateFromState[CustomHydrateFromState[O], struct{}, O](ctx, oldState)