pulumi/pulumi · error
registry.Mock.DownloadTemplateF not implemented
Error message
registry.Mock.DownloadTemplateF not implemented
What it means
Mock.DownloadTemplate panics when its backing function is not implemented. Note the guard checks the wrong field: it tests m.ListTemplatesF instead of m.DownloadTemplateF, so a Mock with ListTemplatesF set but DownloadTemplateF nil still panics with this (misleading) message, and a Mock with DownloadTemplateF set but ListTemplatesF nil panics here even though DownloadTemplateF exists. This is a copy-paste bug in pkg/registry/mock.go:80.
Solutions
- Set DownloadTemplateF on the Mock before calling DownloadTemplate
- Fix the guard to check m.DownloadTemplateF instead of m.ListTemplatesF in pkg/registry/mock.go:80
- Use a Mock constructor that initializes every function field with safe defaults
Example fix
// before (mock.go:80)
if m.ListTemplatesF == nil {
panic("registry.Mock.DownloadTemplateF not implemented")
}
// after
if m.DownloadTemplateF == nil {
panic("registry.Mock.DownloadTemplateF not implemented")
} Defensive patterns
Strategy: validation
Validate before calling
if mock.DownloadTemplateF == nil {
return fmt.Errorf("test setup incomplete: DownloadTemplateF must be set before downloading templates")
} Prevention
- Fix the guard in pkg/registry/mock.go to check m.DownloadTemplateF, not m.ListTemplatesF
- Build Mock instances through a constructor that defaults every function field
- Add a unit test exercising each Mock method with a nil-field Mock to catch wrong-field guards
When it happens
Trigger: Calling Mock.DownloadTemplate when DownloadTemplateF is nil and ListTemplatesF is also nil (correct panic, wrong message), or when ListTemplatesF is non-nil but DownloadTemplateF is nil (panic that misreports ListTemplatesF as the culprit); also any Mock whose guard misfires because only ListTemplatesF was configured.
Common situations: Test fixture stubs template listing but not template download; copying the Mock from a test that only lists templates; confusion when the panic message points at ListTemplatesF while the actual missing field is DownloadTemplateF.
Related errors
- registry.Mock.ListTemplatesF not implemented
- applier's invalid function signature (panic re-raises the…
- callback panicked
- cannot convert an input of type %T to a value of type
- creating zstd encoder
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/de9fa49843fb82c0.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/registry/mock.go:81
) (apitype.TemplateMetadata, error) {
if m.GetTemplateF == nil {
panic("registry.Mock.GetTemplateF not implemented")
}
return m.GetTemplateF(ctx, source, publisher, name, version)
}
func (m Mock) ListTemplates(
ctx context.Context, opts ListTemplatesOptions,
) iter.Seq2[apitype.ListTemplatesResponse, error] {
if m.ListTemplatesF == nil {
panic("registry.Mock.ListTemplatesF not implemented")
}
return m.ListTemplatesF(ctx, opts)
}
func (m Mock) DownloadTemplate(ctx context.Context, downloadURL string) (io.ReadCloser, error) {
if m.ListTemplatesF == nil {
panic("registry.Mock.DownloadTemplateF not implemented")
}
return m.DownloadTemplateF(ctx, downloadURL)
}
View on GitHub (pinned to 793f7b2e16)