Repository: godot
Issue: Bugs with GDExtension API validation logic (`--validate-extension-api` command and CI)
Labels: bug,topic:buildsystem,topic:gdextension

### Tested versions

- Reproducible in 4.4.dev (826de7976a6add282c7b14d4be2a7e6d775821d8), #90993, and older versions too

### System information

Any

### Issue description

We have some bugs in the GDExtension API validation checks that we perform on CI, which are starting to hamper development as we need to work them around in non-trivial ways.

#90993 is a good example of that as it's impacting a complex method, `RenderingDevice::draw_list_begin` which changed multiple times since Godot 4.0:

- In 4.1-stable, its 9th argument was changed from an `Array` to a `TypedArray<RID>` (`Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments/9': type changed value in new API, from "Array" to "typedarray::RID".`).
- In 4.3-stable, its 9th argument was removed (`Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments': size changed value in new API, from 10 to 9.`).
- In #90993 (intended for 4.4-stable), a new 9th argument with a different name, type and default value was added (`Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments': size changed value in new API, from 9 to 10.`).

To make CI checks pass, I had to add changes to `4.0-stable_4.1-stable.expected` and `4.2-stable_4.3-stable.expected` that reflects changes done in 4.4, which seems wrong to me. And also contradicts previous messages in the same `.expected` files for the API breakage done in their respective versions.

```diff
diff --git a/misc/extension_api_validation/4.0-stable_4.1-stable.expected b/misc/extension_api_validation/4.0-stable_4.1-stable.expected
index 5c3bf07fb2..2b7f9dc662 100644
--- a/misc/extension_api_validation/4.0-stable_4.1-stable.expected
+++ b/misc/extension_api_validation/4.0-stable_4.1-stable.expected
@@ -349,3 +349,11 @@ Validate extension JSON: Error: Hash changed for 'classes/EditorUndoRedoManager/
 Validate extension JSON: Error: Hash changed for 'classes/UndoRedo/methods/create_action', from 0AEC1BFC to E87757EB. This means that the function has changed and no compatibility function was provided.
 
 Added a optional parameters with default values. No adjustments should be necessary.
+
+
+GH-90993
+--------
+Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments/9': type changed value in new API, from "Array" to "int".
+
+FIXME: Hack to workaround a bug in our validation logic with a method that changed arguments count, type, and default values multiple times.
+The actual last change triggering this error happened in 4.4 (GH-90993).
diff --git a/misc/extension_api_validation/4.2-stable_4.3-stable.expected b/misc/extension_api_validation/4.2-stable_4.3-stable.expected
index ce8f24c7a9..3de9736c8d 100644
--- a/misc/extension_api_validation/4.2-stable_4.3-stable.expected
+++ b/misc/extension_api_validation/4.2-stable_4.3-stable.expected
@@ -380,3 +380,12 @@ Validate extension JSON: Error: Field 'classes/Image/methods/get_mipmap_offset/r
 
 Type changed to int64_t to support baking large lightmaps.
 No compatibility method needed, both GDExtension and C# generate it as int64_t anyway.
+
+
+GH-90993
+--------
+Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments/9': default_value changed value in new API, from "Array[RID]([])" to "0".
+Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments/9': type changed value in new API, from "typedarray::RID" to "int".
+
+FIXME: Hack to workaround a bug in our validation logic with a method that changed arguments count, type, and default values multiple times.
+The actual last change triggering this error happened in 4.4 (GH-90993).
diff --git a/misc/extension_api_validation/4.3-stable.expected b/misc/extension_api_validation/4.3-stable.expected
index 24c7702090..5c869d9914 100644
--- a/misc/extension_api_validation/4.3-stable.expected
+++ b/misc/extension_api_validation/4.3-stable.expected
@@ -14,3 +14,11 @@ Validate extension JSON: Error: Field 'classes/ShapeCast2D/properties/collision_
 Validate extension JSON: Error: Field 'classes/ShapeCast3D/properties/collision_result': getter changed value in new API, from "_get_collision_result" to &"get_collision_result".
 
 These getters have been renamed to expose them. GDExtension language bindings couldn't have exposed these properties before.
+
+
+GH-90993
+--------
+Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_begin/arguments': size changed value in new API, from 9 to 10.
+
+draw_list_begin added a new optional debug argument called breadcrumb.
+There used to be an RID argument as arg #9 which was removed in GH-84976 but now we're adding a new one in the same location.
```

---

Aside from the above issue, we have a few other long-running problems that trigger recurring warnings in the logs, but somehow don't seem to break the CI checks, or we'd have fixed them ages ago:

```
ERROR: New API lacks base array: enums
   at: compare_dict_array (./core/extension/extension_api_dump.cpp:1362)
```
Happens when checking the `4.0-stable_4.1-stable.expected` and `4.1-stable_4.2-stable.expected` files.

```
ERROR: Validate extension JSON: Missing field in current API 'classes/RenderingDevice/methods/draw_list_end': arguments. This is a bug.
   at: compare_dict_array (./core/extension/extension_api_dump.cpp:1443)
ERROR: Validate extension JSON: Missing field in current API 'classes/RenderingDevice/methods/compute_list_begin': arguments. This is a bug.
   at: compare_dict_array (./core/extension/extension_api_dump.cpp:1443)
ERROR: Validate extension JSON: Missing field in current API 'classes/RenderingDevice/methods/compute_list_end': arguments. This is a bug.
   at: compare_dict_array (./core/extension/extension_api_dump.cpp:1443)
```
Happens for all stable version checks, but somehow not in the dev version (currently `4.3-stable.expected`). This was the same in the previous dev cycle where it didn't occur for `4.2-stable.expected`, so it's not that it was fixed in 4.3 / 4.4.dev.

### Steps to reproduce

```
./misc/scripts/validate_extension_api.sh godot
```

### Minimal reproduction project (MRP)

n/a