{"record":{"id":"94b4c2a5e2b4a16b","repo":"microsoft/aspire","slug":"resource-resource-name-cannot-resolve-the","errorCode":null,"errorMessage":"Resource '{resource.Name}' cannot resolve the '{environmentVariableName}' persistent-volume path in run mode. Only project, executable, and container resources are supported.","messagePattern":"Resource '(.+?)' cannot resolve the '(.+?)' persistent-volume path in run mode\\. Only project, executable, and container resources are supported\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentExtensions.cs","lineNumber":118,"sourceCode":"            .ToArray();\n    }\n\n    private static void ValidateRunModePersistentVolumeBindings(PersistentVolumeBinding[] bindings)\n    {\n        ValidateRunModeVolumeNamesAreUnambiguous(bindings);\n\n        foreach (var (resource, annotation) in bindings)\n        {\n            // The env can be spelled on the binding or on a separate name-matched mount, and both make\n            // the resource resolve the same local store path, so an unsupported resource shape has to\n            // be rejected for either spelling. Without this, a custom compute resource still receives\n            // the store path while the compatibility check below treats it as publish-only.\n            var environmentVariableName = GetLocalPathEnvironmentVariableName(resource, annotation);\n\n            if (environmentVariableName is not null &&\n                resource is not ProjectResource and not ExecutableResource and not ContainerResource)\n            {\n                throw new DistributedApplicationException(\n                    $\"Resource '{resource.Name}' cannot resolve the '{environmentVariableName}' persistent-volume path in run mode. \" +\n                    $\"Only project, executable, and container resources are supported.\");\n            }\n        }\n\n        ValidateRunModeBackingStoreCompatibility(bindings);\n    }\n\n    private static void ValidateRunModeVolumeNamesAreUnambiguous(PersistentVolumeBinding[] bindings)\n    {\n        // Only run mode can reach this. Publish mode registers each volume with AddResource, so a second\n        // volume sharing a name fails global resource-name uniqueness while the model is still being\n        // built. Run mode hands back a CreateResourceBuilder that never registers the volume, so the\n        // collision survives to here.\n        //\n        // Both run-mode paths key off the volume name alone — the local path lookup in\n        // VolumeMountBindingAnnotation.ResolvePath and the container mount rewrite in\n        // ApplyRunModeContainerVolumeName — so two distinct volumes sharing a name on one resource would","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentExtensions.cs#L100-L136","documentation":"In run mode, Kubernetes persistent-volume bindings are emulated by resolving a local path environment variable. Only ProjectResource, ExecutableResource, and ContainerResource have a supported local execution story, so any other resource type bound to a persistent volume throws DistributedApplicationException.","triggerScenarios":"Calling WithVolume/WithPersistentVolume-style binding on a resource that is not a project, executable, or container (e.g. a custom IResource or connection-resource type) and running the AppHost in run mode.","commonSituations":"Custom resource types in an AppHost binding Kubernetes volumes; third-party resources that support volumes only at publish time being run locally.","solutions":["Bind the persistent volume only to project, executable, or container resources.","Implement local path resolution support for the custom resource type, or gate the volume binding behind publish mode.","Remove the volume binding if the resource does not need local persistent storage."],"exampleFix":"// before\nvar custom = builder.AddResource<MyCustomResource>(\"custom\").WithPersistentVolume(...);\n// after\nvar svc = builder.AddContainer(\"svc\", \"image\").WithPersistentVolume(...);","handlingStrategy":"type-guard","validationCode":"bool supportsVolumes = resource is ProjectResource or ExecutableResource or ContainerResource;","typeGuard":"bool SupportsKubernetesVolumes(IResource r) => r is ProjectResource or ExecutableResource or ContainerResource;","tryCatchPattern":"try { RunAppHostAsync(); } catch (DistributedApplicationException ex) when (ex.Message.Contains(\"persistent-volume path in run mode\")) { /* remove or re-target volume binding */ }","preventionTips":["Only bind persistent volumes to project, executable, or container resources","Gate volume bindings behind publish mode for custom resources","Review custom IResource implementations for run-mode support"],"tags":["kubernetes","volumes","run-mode","unsupported"],"backgroundTag":"unsupported-operation","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"}