From 18a68b17e21915b2ff0cd54a0aa72424c018eac7 Mon Sep 17 00:00:00 2001 From: Archana Asokan Date: Mon, 2 Mar 2026 08:56:25 -0500 Subject: [PATCH] Fix BDD test lookup to handle oneOf wrappers for array indexing When a oneOf schema wraps an array type, the World.lookup method needs to unwrap the getActualInstance() before casting to List. This fixes ClassCastException when BDD steps navigate paths like group_by[0].facet where group_by is now a oneOf wrapper. This matches the spec change in datadog-api-spec PR #5141. --- src/test/java/com/datadog/api/World.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/datadog/api/World.java b/src/test/java/com/datadog/api/World.java index 7cf1d7e8ce3..9b81f40d968 100644 --- a/src/test/java/com/datadog/api/World.java +++ b/src/test/java/com/datadog/api/World.java @@ -681,7 +681,17 @@ public static Object lookup(Object data, String path) } if (part.contains("]")) { int index = Integer.parseInt(part.replaceAll("]", "")); - result = List.class.cast(result).get(index); + // Unwrap oneOf wrapper before indexing into array + try { + result = List.class.cast(result).get(index); + } catch (ClassCastException e) { + try { + Object unwrapped = result.getClass().getMethod("getActualInstance").invoke(result); + result = List.class.cast(unwrapped).get(index); + } catch (Exception ex) { + throw e; + } + } } else { try { result = HashMap.class.cast(result).get(part);