{"record":{"id":"e24ea5b5a20e0bc0","repo":"microsoft/aspire","slug":"unknown-path-type","errorCode":null,"errorMessage":"Unknown path type.","messagePattern":"Unknown path type\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/KubernetesIngressExtensions.cs","lineNumber":388,"sourceCode":"        ArgumentNullException.ThrowIfNull(builder);\n        ArgumentException.ThrowIfNullOrEmpty(key);\n        ArgumentNullException.ThrowIfNull(value);\n\n        builder.Resource.IngressAnnotations[key] = ReferenceExpression.Create($\"{value.Resource}\");\n        return builder;\n    }\n\n    /// <summary>\n    /// Converts an <see cref=\"IngressPathType\"/> enum value to the Kubernetes API string representation.\n    /// </summary>\n    internal static string ToKubernetesString(this IngressPathType pathType)\n    {\n        return pathType switch\n        {\n            IngressPathType.Prefix => \"Prefix\",\n            IngressPathType.Exact => \"Exact\",\n            IngressPathType.ImplementationSpecific => \"ImplementationSpecific\",\n            _ => throw new ArgumentOutOfRangeException(nameof(pathType), pathType, \"Unknown path type.\")\n        };\n    }\n}\n","sourceCodeStart":370,"sourceCodeEnd":392,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/KubernetesIngressExtensions.cs#L370-L392","documentation":"ToKubernetesString converts an IngressPathType enum value to the Kubernetes ingress pathType string. The library throws this ArgumentOutOfRangeException when the enum value is not one of the three defined members (Prefix, Exact, ImplementationSpecific). This guards against an enum value added in a newer Aspire version or a cast from an arbitrary int that has no Kubernetes representation.","triggerScenarios":"Calling ToKubernetesString with an IngressPathType value outside the three defined members, typically via an unchecked cast like (IngressPathType)99, or when code compiled against a newer enum member runs against this switch that does not handle it.","commonSituations":"Persisting or deserializing ingress path type configuration from user config files or environment values where an integer was cast blindly to the enum; mixing package versions where one defines an extra IngressPathType member.","solutions":["Use only IngressPathType.Prefix, IngressPathType.Exact, or IngressPathType.ImplementationSpecific when configuring ingress paths.","When reading path type values from config or external input, validate them against Enum.IsDefined<IngressPathType>(value) before casting/using.","Update the Aspire.Hosting.Kubernetes package to a version consistent with the code defining the enum value being passed."],"exampleFix":"// before\nvar pathType = (IngressPathType)int.Parse(config[\"pathType\"]);\n// after\nvar raw = int.Parse(config[\"pathType\"]);\nif (!Enum.IsDefined(typeof(IngressPathType), raw))\n{\n    throw new ArgumentException($\"Unsupported ingress pathType: {raw}\");\n}\nvar pathType = (IngressPathType)raw;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(IngressPathType), pathType))\n{\n    throw new ArgumentException($\"Unsupported IngressPathType: {pathType}\", nameof(pathType));\n}","typeGuard":"static bool IsKnownPathType(IngressPathType value) =>\n    value is IngressPathType.Prefix or IngressPathType.Exact or IngressPathType.ImplementationSpecific;","tryCatchPattern":"try\n{\n    var s = KubernetesIngressExtensions.ToKubernetesString(pathType);\n}\ncatch (ArgumentOutOfRangeException ex)\n{\n    // ex.ParamName == \"pathType\"; log and fall back to \"ImplementationSpecific\"\n}","preventionTips":["Never cast raw ints to IngressPathType without Enum.IsDefined validation.","Keep Aspire.Hosting.Kubernetes package versions aligned across projects.","Default to ImplementationSpecific when the path type is unknown or configurable."],"tags":["kubernetes","ingress","enum","argument-out-of-range"],"backgroundTag":"argument-out-of-range","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"}