{"record":{"id":"5b27b0f5cf96f24b","repo":"microsoft/aspire","slug":"azure-sandbox-deployment-state-for-resource-resource","errorCode":null,"errorMessage":"Azure sandbox deployment state for resource '{_resource.TargetResource.Name}' endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' contains invalid URL '{url}'.","messagePattern":"Azure sandbox deployment state for resource '(.+?)' endpoint '(.+?)' contains invalid URL '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs","lineNumber":101,"sourceCode":"\n    private string? GetKnownValueWithoutDeploymentState()\n    {\n        return _endpointReferenceExpression.Property switch\n        {\n            EndpointProperty.TargetPort => _targetPort.ToString(CultureInfo.InvariantCulture),\n            EndpointProperty.Scheme => Uri.UriSchemeHttps,\n            EndpointProperty.Port => \"443\",\n            EndpointProperty.TlsEnabled => bool.TrueString,\n            _ => null\n        };\n    }\n\n    private string GetValueFromUrl(string url)\n    {\n        if (!Uri.TryCreate(url, UriKind.Absolute, out var uri) ||\n            string.IsNullOrWhiteSpace(uri.Host))\n        {\n            throw new InvalidOperationException($\"Azure sandbox deployment state for resource '{_resource.TargetResource.Name}' endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' contains invalid URL '{url}'.\");\n        }\n\n        return _endpointReferenceExpression.Property switch\n        {\n            EndpointProperty.Url => url,\n            EndpointProperty.Host or EndpointProperty.IPV4Host => uri.Host,\n            EndpointProperty.Port => uri.Port.ToString(CultureInfo.InvariantCulture),\n            EndpointProperty.TargetPort => _targetPort.ToString(CultureInfo.InvariantCulture),\n            EndpointProperty.Scheme => uri.Scheme,\n            EndpointProperty.HostAndPort => uri.IsDefaultPort ? uri.Host : uri.Authority,\n            EndpointProperty.TlsEnabled => string.Equals(uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) ? bool.TrueString : bool.FalseString,\n            _ => throw new InvalidOperationException($\"The property '{_endpointReferenceExpression.Property}' is not supported for the endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}'.\")\n        };\n    }\n\n    private InvalidOperationException CreateUnresolvedEndpointException() =>\n        new($\"Azure sandbox endpoint '{_endpointReferenceExpression.Endpoint.EndpointName}' on resource '{_resource.TargetResource.Name}' does not have a deployed URL yet. Runtime sandbox URLs cannot be used as first-pass Azure provisioning values; deploy the producing sandbox before resolving this reference.\");\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs#L83-L119","documentation":"Thrown by GetValueFromUrl when the URL stored in the sandbox deployment state for an endpoint cannot be parsed as an absolute URI or has an empty host. The provider maps endpoint properties (host, port, scheme, etc.) onto this URL and rejects anything unparseable.","triggerScenarios":"GetValueAsync reading a persisted Ports entry whose Url string is malformed (relative, empty, or missing host) and passing it to GetValueFromUrl; Uri.TryCreate fails or uri.Host is whitespace.","commonSituations":"Deployment state hand-edited with an invalid URL; an older/partial deployment wrote a placeholder URL; the ADC proxy URL was truncated when persisted.","solutions":["Re-run the sandbox deployment so a valid absolute URL (e.g. https://<id>--8080.<region>.adcproxy.io/) is persisted in the Ports section.","Inspect the deployment state's Ports array and fix or remove the malformed Url entry.","Verify the URL includes scheme and host exactly as produced by the deployment (absolute URI required).","If the state is stale, delete it and let the deployment regenerate it."],"exampleFix":"// before\n{ \"Ports\": [{ \"Name\": \"http\", \"Port\": 8080, \"Url\": \"localhost:8080\" }] }\n// after\n{ \"Ports\": [{ \"Name\": \"http\", \"Port\": 8080, \"Url\": \"https://sbx123--8080.eastus.adcproxy.io/\" }] }","handlingStrategy":"validation","validationCode":"bool IsValidAbsoluteUrl(string url) =>\n    Uri.TryCreate(url, UriKind.Absolute, out var u) && !string.IsNullOrWhiteSpace(u.Host);","typeGuard":null,"tryCatchPattern":"try { var host = await provider.GetValueAsync(); }\ncatch (InvalidOperationException ex) { logger.LogError(ex, \"Invalid sandbox URL in state\"); throw; }","preventionTips":["Never hand-edit persisted sandbox URLs in deployment state.","Redeploy if state entries look truncated or placeholder-like.","Validate the Ports section schema after each deployment."],"tags":["azure","sandbox","url","deployment-state"],"backgroundTag":"invalid-url-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}