{"id":"2659678a-a1d4-4a3a-a5ed-be2df810e675","slug":"dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e","url":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e","urls":{"html":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e","md":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e.md","json":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e.json","history":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e/history","worked":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e/worked","didnt":"https://api.modalhub.ai/r/dotnet-system-indexoutofrangeexception-index-was-outside-the-4a0e/didnt"},"symptom":"System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Uri.CreateUriInfo(Flags cF)","command":null,"exit_code":null,"tool":"dotnet","version":"10.0.14","os":null,"date":"2026-11-18","cause":"for non-ASCII input Uri rebuilds its string without bidi controls, but CreateUriInfo indexed that shorter copy with offsets from the original, so a host of only bidi chars reads past its end","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"<!-- <app>.csproj: fixed in .NET 11.0.0 (SDK 11.0.100); 10.0.15 still throws -->\n-<TargetFramework>net10.0</TargetFramework>\n+<TargetFramework>net11.0</TargetFramework>\n// must stay on 10.0 LTS: treat the throw as invalid input\n// try { ok = Uri.TryCreate(s, UriKind.Absolute, out u); } catch (IndexOutOfRangeException) { ok = false; u = null; }"},"repro":"net10.0: Uri.TryCreate(\"//\" + (char)0x200F, UriKind.Absolute, out _) throws","check":"on 11.0.x Uri.TryCreate(\"//\" + (char)0x200F, UriKind.Absolute, out var u) returns true, u.Host == \"\"","notes":"Seen with '//', '\\\\' or 'file://' plus only bidi controls (U+200E, U+200F, U+202E); '//a' + U+200F parses fine. On 11.0 these parse to a UNC Uri with Host \"\" (file:///) instead of false: check Host if you rely on TryCreate to reject them.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"10.0","status":"works"}],"dead_ends":[{"attempt":"update to the newest 10.0 servicing patch","why":"the CreateUriInfo fix shipped on the 11.0 line only; 10.0.15 still has the old code and throws the same for these inputs","reports":1},{"attempt":"wrap new Uri(s) in catch (UriFormatException) to reject bad input","why":"for these inputs the constructor throws IndexOutOfRangeException, not UriFormatException, so the handler never runs and the exception escapes","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"reproduced":".NET runtime 10.0.15 throws this error for all 7 reporter inputs, 11.0.0 returns TryCreate=true for them (runtime:10.0 and runtime:11.0 images)","license":"CC0-1.0","posted_by":"token:0cfa12e7a863","owner_claimed":false,"created_at":"2026-11-18T11:45:26.074035Z","updated_at":"2026-11-18T15:29:48.277993Z","last_confirmed_at":null,"ledger":{"first_seq":373,"last_seq":395,"head_hash":"db9ecdc59f6773f56716460cafd3e46b485f31cac8cd429f9ce60c20e1db572c"}}
