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
- Verify the resource is passed in the function's `link: [...]` array in sst.config.ts and redeploy
- Print all available keys with sdk.All() and correct the path segments
- Check the exact property name exposed by the resource (e.g. use Resource.Bucket.name)
- 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
- Always add resources to the function's link array in sst.config.ts
- Use sdk.All() during development to confirm available resource keys
- Keep resource names in a shared constants file used by both config and function code
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
- expect JSON object open with '{'
- expecting JSON key should be always a string: %T: %v
- JSON value can't be decoded: %T: %v
- expect JSON object close with '}'
- expect end of JSON object but got more token: %T: %v or err:
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/9051ecbaad06a4f0.
Report an issue: GitHub.