Skip to content

[jnigen] Report an empty config list entry as a config error - #3514

Merged
liamappelbe merged 3 commits into
dart-lang:mainfrom
Yusufihsangorgel:issue-1802-empty-config-entry
Sep 15, 2026
Merged

liamappelbe merged 3 commits into
dart-lang:mainfrom
Yusufihsangorgel:issue-1802-empty-config-entry

Conversation

@Yusufihsangorgel

@Yusufihsangorgel Yusufihsangorgel commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

An empty item under classes reads as a YAML null, and the list is cast lazily, which leaves the first read of that element failing with a TypeError that never names the key.

Now parseArgs maps a null entry to an empty name and the class name check rejects it with a ConfigException. The test writes its own YAML file, since a -D override cannot express an empty list entry.

Fixes #1802

@liamappelbe

Copy link
Copy Markdown
Contributor

Hi @Yusufihsangorgel. Sorry for the delay. I wanted to land some updates to the JNIgen config API before I looked at this. The API has been heavily refactored, so you'll need to sync to head to start with.

High level feedback:

  • The piece of code that caused the exception you saw doesn't exist anymore. Is this issue still reproducible on main?
  • Your fix only seems to cover the YAML format, but the stack trace appears to be common to both the YAML format and the Dart config API. I'm planning to deprecate the YAML format soon and only support the Dart API. Is the error reproducible using the Dart API? Can your fix be moved to a place where it covers both formats?

@Yusufihsangorgel
Yusufihsangorgel force-pushed the issue-1802-empty-config-entry branch from 237b3a4 to 0cea928 Compare September 4, 2026 14:51
}) : workingDirectory = workingDirectory ?? Uri.directory('.') {
for (final className in classes) {
_validateClassName(className);
final entries = classes.cast<Object?>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird. Also, your Dart API test has to be very artificial to trigger this.

Maybe a better fix would be to change parseArgs so that this classes field never contains null. Like, default a null string to ''. Then you wouldn't need this check because the existing _validateClassName check throws an error if the name is empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapped a null entry to an empty name in parseArgs, as suggested. The class name check never rejected an empty string, and that is the one line I added.

@Yusufihsangorgel

Copy link
Copy Markdown
Contributor Author

Still a TypeError on main for an empty YAML classes entry. The Dart API cannot put that null into Input.classes without a cast. parseArgs is YAML-only, and I map the null there. The _validateClassName check on Input covers both paths.

@liamappelbe
liamappelbe merged commit 1b331f1 into dart-lang:main Sep 15, 2026
73 of 75 checks passed
Hassnaa9 pushed a commit to Hassnaa9/native that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jnigen crashes on empty string in jnigen.yaml classes: section

2 participants