{"record":{"id":"614175f63431c240","repo":"pulumi/pulumi","slug":"registry-mock-listpackagesf-not-implemented","errorCode":null,"errorMessage":"registry.Mock.ListPackagesF not implemented","messagePattern":"registry\\.Mock\\.ListPackagesF not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/registry/mock.go","lineNumber":56,"sourceCode":"\t) (apitype.TemplateMetadata, error)\n\n\tListTemplatesF func(ctx context.Context, opts ListTemplatesOptions) iter.Seq2[apitype.ListTemplatesResponse, error]\n\n\tDownloadTemplateF func(ctx context.Context, downloadURL string) (io.ReadCloser, error)\n}\n\nfunc (m Mock) GetPackage(\n\tctx context.Context, source, publisher, name string, version *semver.Version,\n) (apitype.PackageMetadata, error) {\n\tif m.GetPackageF == nil {\n\t\tpanic(\"registry.Mock.GetPackageF not implemented\")\n\t}\n\treturn m.GetPackageF(ctx, source, publisher, name, version)\n}\n\nfunc (m Mock) ListPackages(ctx context.Context, name *string) iter.Seq2[apitype.PackageMetadata, error] {\n\tif m.ListPackagesF == nil {\n\t\tpanic(\"registry.Mock.ListPackagesF not implemented\")\n\t}\n\treturn m.ListPackagesF(ctx, name)\n}\n\nfunc (m Mock) GetTemplate(\n\tctx context.Context, source, publisher, name string, version *semver.Version,\n) (apitype.TemplateMetadata, error) {\n\tif m.GetTemplateF == nil {\n\t\tpanic(\"registry.Mock.GetTemplateF not implemented\")\n\t}\n\treturn m.GetTemplateF(ctx, source, publisher, name, version)\n}\n\nfunc (m Mock) ListTemplates(\n\tctx context.Context, opts ListTemplatesOptions,\n) iter.Seq2[apitype.ListTemplatesResponse, error] {\n\tif m.ListTemplatesF == nil {\n\t\tpanic(\"registry.Mock.ListTemplatesF not implemented\")","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/registry/mock.go#L38-L74","documentation":"registry.Mock.ListPackages iterates packages via the ListPackagesF function field; if that field is nil the mock was never configured for listing and it panics with this message rather than returning an empty or fake sequence.","triggerScenarios":"Code under test calls Mock.ListPackages (e.g. pulumi package list or search flows) while the test's Mock lacks ListPackagesF, or a test exercising a newly added list path with an older fixture.","commonSituations":"Existing tests re-used after production code started calling ListPackages; forgetting to stub iterator-returning methods when setting up the registry mock; incremental interface changes leaving fixtures incomplete.","solutions":["Set ListPackagesF in the test fixture, e.g. ListPackagesF: func(name *string) iter.Seq2[apitype.PackageMetadata, error] { ... } returning a small sequence","If listing isn't relevant to the test, route the code under test to a different dependency or stub it","Add a default-populated Mock constructor to keep fixtures complete","Update stale test setups after registry interface changes"],"exampleFix":"// before\nmock := registry.Mock{}\n// after\nmock := registry.Mock{\n  ListPackagesF: func(name *string) iter.Seq2[apitype.PackageMetadata, error] {\n    return func(yield func(apitype.PackageMetadata, error) bool) {\n      yield(apitype.PackageMetadata{Name: deref(name)}, nil)\n    }\n  },\n}","handlingStrategy":"validation","validationCode":"if mock.ListPackagesF == nil {\n  t.Fatal(\"test bug: registry.Mock.ListPackagesF must be set before use\")\n}","typeGuard":"func configuredListPackages(m registry.Mock) bool { return m.ListPackagesF != nil }","tryCatchPattern":"// panic is intentional; guard in test setup:\nrequire.NotNil(t, mock.ListPackagesF, \"ListPackagesF not configured\")","preventionTips":["Stub list methods (iterators) when setting up the mock, not only get methods","Re-check mock completeness after adding list-based call paths in production code","Use a shared fixture builder that fills all fields"],"tags":["testing","mock","registry","panic"],"backgroundTag":"mock-not-configured","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}