anomalyco/sst · error · ErrNotFound

not found

Error message

not found

What it means

The Go runtime SDK's Get() walks the linked-resource tree and returns ErrNotFound (a sentinel from errors.New) when the requested path does not exist in the resources map loaded from the encrypted resource payload. It signals that either no resources were linked to this function or the path segments are wrong.

Source

Thrown at sdk/golang/resource/resource.go:65

	// In Go, we pass the auth tag as part of the ciphertext
	ciphertextWithTag := append(actualCiphertext, authTag...)

	// Decrypt
	decrypted, err := aesGCM.Open(nil, nonce, ciphertextWithTag, nil)
	if err != nil {
		resources = make(map[string]any)
		return
	}

	// Parse JSON
	if err := json.Unmarshal(decrypted, &resources); err != nil {
		resources = make(map[string]any)
		return
	}
}

var ErrNotFound = errors.New("not found")

func Get(path ...string) (any, error) {
	return get(resources, path...)
}

func All() map[string]any {
	return resources
}

func get(input any, path ...string) (any, error) {
	if len(path) == 0 {
		return input, nil
	}
	casted, ok := input.(map[string]any)
	if !ok {
		return nil, ErrNotFound
	}
	next, ok := casted[path[0]]

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Verify the resource is passed in the function's `link: [...]` array in sst.config.ts and redeploy
  2. Print all available keys with sdk.All() and correct the path segments
  3. Check the exact property name exposed by the resource (e.g. use Resource.Bucket.name)
  4. Ensure the function runs via sst dev / deployed with SST so the resource metadata file exists

Example fix

// before
bucketArn := sdk.Get("MyBucket").(map[string]any)["arn"]
// after
val, err := sdk.Get("MyBucket", "arn")
if errors.Is(err, sdk.ErrNotFound) {
    log.Fatalf("MyBucket not linked: %v", sdk.All())
}
Defensive patterns

Strategy: try-catch

Validate before calling

if avail := sdk.All(); len(avail) == 0 {
    return fmt.Errorf("no resources linked to this function")
}

Type guard

func resourceExists(path ...string) bool {
    _, err := sdk.Get(path...)
    return !errors.Is(err, sdk.ErrNotFound)
}

Try / catch

val, err := sdk.Get("MyBucket", "arn")
if err != nil {
    if errors.Is(err, sdk.ErrNotFound) {
        // handle missing link: log available keys and fail fast
    }
    return err
}

Prevention

When it happens

Trigger: Calling sdk.Get("Bucket", "arn") where the resource name or property key is misspelled, or calling Get before resources finish loading (e.g. during cold start in a non-SST runtime), or when no resource is linked via sst.Linkable/links.

Common situations: Renaming a resource in sst.config.ts but not in the function code; typos in property paths like 'bucketName' vs 'name'; forgetting to add the resource to the function's links; running the handler outside `sst dev` so the resource file is absent (resources stays an empty map).

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/9051ecbaad06a4f0. Report an issue: GitHub.