{"record":{"id":"986b374af003aad0","repo":"microsoft/aspire","slug":"failed-to-retrieve-container-registry-information-986b37","errorCode":null,"errorMessage":"Failed to retrieve container registry information.","messagePattern":"Failed to retrieve container registry information\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/PipelineStepHelpers.cs","lineNumber":109,"sourceCode":"                    new MarkdownString($\"Successfully tagged **{resource.Name}** as `{targetTag}`\"),\n                    CompletionState.Completed,\n                    context.CancellationToken).ConfigureAwait(false);\n            }\n            catch (Exception ex)\n            {\n                await tagTask.CompleteAsync(\n                    new MarkdownString($\"Failed to tag **{resource.Name}**: {ex.Message}\"),\n                    CompletionState.CompletedWithError,\n                    context.CancellationToken).ConfigureAwait(false);\n                throw;\n            }\n        }\n    }\n\n    private static async Task PushImageToRemoteRegistryAsync(IResource resource, IContainerRegistry registry, PipelineStepContext context)\n    {\n        var registryName = await registry.Name.GetValueAsync(context.CancellationToken).ConfigureAwait(false)\n            ?? throw new InvalidOperationException(\"Failed to retrieve container registry information.\");\n\n        IValueProvider cir = new ContainerImageReference(resource);\n        var targetTag = await cir.GetValueAsync(new ValueProviderContext { ExecutionContext = context.ExecutionContext }, context.CancellationToken).ConfigureAwait(false);\n\n        var pushTask = await context.ReportingStep.CreateTaskAsync(\n            new MarkdownString($\"Pushing **{resource.Name}** to **{registryName}**\"),\n            context.CancellationToken).ConfigureAwait(false);\n\n        await using (pushTask.ConfigureAwait(false))\n        {\n            try\n            {\n                if (targetTag is null)\n                {\n                    throw new InvalidOperationException($\"Failed to get target tag for {resource.Name}\");\n                }\n\n                var containerImageManager = context.Services.GetRequiredService<IResourceContainerImageManager>();","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/PipelineStepHelpers.cs#L91-L127","documentation":"PushImageToRemoteRegistryAsync resolves the target registry's name via IContainerRegistry.Name.GetValueAsync. The registry name is a required ReferenceExpression; when it evaluates to null the helper cannot form the push destination and throws InvalidOperationException('Failed to retrieve container registry information.').","triggerScenarios":"Pushing an image where registry.Name (a ReferenceExpression) evaluates to null — e.g. a custom IContainerRegistry with an unset/empty Name expression, or Azure/AWS registry resources whose name inputs (resource group, account id, env values) were not resolved at that point.","commonSituations":"Custom IContainerRegistry implementations returning a Name expression built from unresolved publish-time parameters, running push steps outside the expected publish context where registry inputs are absent, misconfigured Azure CDK/provisioning outputs so the registry name output never materializes.","solutions":["Ensure the IContainerRegistry's Name expression references only inputs available at publish time and is non-empty.","Verify the underlying registry resource is correctly configured (name, resource group, subscription) before the push step.","For custom registries, implement Name to return a valid ReferenceExpression rather than null/empty.","Run the push within the normal publish pipeline so provisioning outputs (registry name) have been resolved."],"exampleFix":"// before\nvar registry = new CustomRegistry(); // Name expression never set\nbuilder.AddRegistry(registry);\n// after\nvar registry = new CustomRegistry();\nregistry.Name = ReferenceExpression.Create($\"{parameters.RegistryName}\");\nbuilder.AddRegistry(registry);","handlingStrategy":"validation","validationCode":"var name = await registry.Name.GetValueAsync(ctx);\nif (string.IsNullOrWhiteSpace(name)) throw new InvalidOperationException(\"Registry name not configured.\");","typeGuard":"bool IsRegistryConfigured(IContainerRegistry r) => r.Name is not null;","tryCatchPattern":"try { await PushAsync(resource, registry, context); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Failed to retrieve container registry information\")) { context.ReportingStep.Complete(CompletionState.WithError, \"Registry information missing; check registry configuration.\", false); }","preventionTips":["Configure registry Name expressions with publish-time-resolvable inputs","For custom IContainerRegistry, always provide a non-empty ReferenceExpression for Name","Ensure the push step runs inside the publish pipeline so provisioning outputs resolve","Validate registry configuration (name/resource group/subscription) before running push steps"],"tags":["container-registry","publish-pipeline","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}