From 93848c4c09d3bbd845c078499532ecea53b160e6 Mon Sep 17 00:00:00 2001 From: wixoa Date: Mon, 9 Mar 2026 00:21:19 -0400 Subject: [PATCH] `atom.filters["doesnt_exist"]` returns null --- OpenDreamRuntime/Objects/Types/DreamList.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 593975ceff..db80bf71b5 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -1080,16 +1080,14 @@ public override DreamValue GetValue(DreamValue key) { int filterIndex; if (key.TryGetValueAsString(out var filterName)) { filterIndex = GetIndexOfFilter(filterName) + 1; // We're 1-indexed while GetIndexOfFilter() is not + if (filterIndex < 1) // If a filter by the name doesn't exist, it returns null + return DreamValue.Null; } else { key.TryGetValueAsInteger(out filterIndex); } - if (filterIndex < 1) { // The key failed to resolve to a valid index - throw new Exception($"Invalid index into filter list: {key}"); - } - ImmutableAppearance appearance = GetAppearance(); - if (filterIndex > appearance.Filters.Length) + if (filterIndex < 1 || filterIndex > appearance.Filters.Length) throw new Exception($"Atom only has {appearance.Filters.Length} filter(s), cannot index {filterIndex}"); DreamFilter filter = appearance.Filters[filterIndex - 1];