{"record":{"id":"a9cfe1cc34e37e6a","repo":"microsoft/aspire","slug":"unsupported-storage-type-context-parent-defaultstoragetype","errorCode":null,"errorMessage":"Unsupported storage type: {context.Parent.DefaultStorageType}","messagePattern":"Unsupported storage type: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs","lineNumber":286,"sourceCode":"\n                case \"pvc\":\n                    // Only emit a PersistentVolumeClaim — the cluster's StorageClass\n                    // (named by DefaultStorageClassName or the cluster default) drives\n                    // dynamic provisioning of the backing PersistentVolume. Statically\n                    // pre-provisioned PVs are only emitted by the first-class\n                    // KubernetesPersistentVolumeResource path above; emitting a bare PV\n                    // here would be missing a PersistentVolumeSource (csi/hostPath/local\n                    // /nfs/...) and would be rejected by `kubectl apply`. See\n                    // https://kubernetes.io/docs/concepts/storage/persistent-volumes/#dynamic.\n                    var pvc = CreatePersistentVolumeClaim(context, volume);\n                    podVolume.PersistentVolumeClaim = new()\n                    {\n                        ClaimName = pvc.Metadata.Name,\n                    };\n                    break;\n\n                default:\n                    throw new InvalidOperationException($\"Unsupported storage type: {context.Parent.DefaultStorageType}\");\n            }\n\n            podTemplateSpec.Spec.Volumes.Add(podVolume);\n        }\n\n        return podTemplateSpec;\n    }\n\n    private static ContainerV1 ToContainerV1(this IResource resource, KubernetesResource context)\n    {\n        var container = new ContainerV1\n        {\n            Name = resource.Name,\n            ImagePullPolicy = context.Parent.DefaultImagePullPolicy,\n        };\n\n        return container\n            .WithContainerImage(context)","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/Extensions/ResourceExtensions.cs#L268-L304","documentation":"When generating pod template volumes, the Kubernetes publisher switches on the resource's DefaultStorageType. Only known storage kinds (e.g. empty-dir, PVC) are supported; any other value hits the default case and throws InvalidOperationException. This is an internal invariant guard against unrecognized storage configurations.","triggerScenarios":"A resource with volumes whose DefaultStorageType holds a value the Kubernetes publisher does not map, evaluated in WithPodSpecVolumes during publish.","commonSituations":"A newly introduced storage type not yet handled by the Kubernetes publisher; a custom resource setting DefaultStorageType to an unexpected value; version skew where hosting added a storage kind before the Kubernetes publisher supported it.","solutions":["Use a supported storage type for the resource's volumes (persisted volume / empty-dir as applicable).","Upgrade to the latest Aspire version where the storage type may be supported.","Remove or reconfigure the volume on the resource so DefaultStorageType falls within supported values.","If the value comes from your own resource extension, set it to a recognized storage kind."],"exampleFix":"// before\nvar cache = builder.AddRedis(\"cache\")\n    .WithDataVolume(storageType: /* unsupported custom kind */);\n// after\nvar cache = builder.AddRedis(\"cache\")\n    .WithDataVolume(); // uses a storage type the Kubernetes publisher supports","handlingStrategy":"validation","validationCode":"var supported = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { \"EmptyDir\", \"PersistentVolume\" };\nif (!supported.Contains(resource.DefaultStorageType))\n{\n    throw new InvalidOperationException($\"Storage type '{resource.DefaultStorageType}' is not supported by the Kubernetes publisher.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use storage types documented as supported by the Kubernetes publisher.","Pin to a supported Aspire version or upgrade when adding new volume kinds.","Check the switch in ResourceExtensions.WithPodSpecVolumes when introducing custom storage types."],"tags":["kubernetes","volumes","storage","publish"],"backgroundTag":"unsupported-enum-value","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"}