Skip to content

Fix dropdown options reflection error with kb-sdk validate #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged

Conversation

MrCreosote
Copy link
Member

Bug found by the kb_djornl author:

Exception in thread "main"
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program
tried to reflectively invoke method public
us.kbase.narrativemethodstore.DropdownOptions() without it being
registered for runtime reflection.

* large stack trace with JsonClientCaller and Jackson methods snipped*

	at us.kbase.narrativemethodstore.NarrativeMethodStoreClient.validateMethod(NarrativeMethodStoreClient.java:526)

	at us.kbase.sdk.validator.ModuleValidator.validateMethodSpec(ModuleValidator.java:236)

	at us.kbase.sdk.validator.ModuleValidator.validate(ModuleValidator.java:168)

	at us.kbase.sdk.tester.ModuleTester.runTests(ModuleTester.java:94)

	at us.kbase.sdk.ModuleBuilder$TestCommand.call(ModuleBuilder.java:445)

	at us.kbase.sdk.ModuleBuilder$TestCommand.call(ModuleBuilder.java:431)

	at picocli.CommandLine.executeUserObject(CommandLine.java:2031)

Fixed this bug and other potential bugs around NMS classes not being fully accessible by making all methods, fields, and constructors available for reflection.

Tested with the kb_staging_exporter app, which also has dropdown_option in spec.json, by running kb-sdk validate.

Bug found by the `kb_djornl` author:

```
Exception in thread "main"
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program
tried to reflectively invoke method public
us.kbase.narrativemethodstore.DropdownOptions() without it being
registered for runtime reflection.

* large stack trace with JsonClientCaller and Jackson methods snipped*

	at us.kbase.narrativemethodstore.NarrativeMethodStoreClient.validateMethod(NarrativeMethodStoreClient.java:526)

	at us.kbase.sdk.validator.ModuleValidator.validateMethodSpec(ModuleValidator.java:236)

	at us.kbase.sdk.validator.ModuleValidator.validate(ModuleValidator.java:168)

	at us.kbase.sdk.tester.ModuleTester.runTests(ModuleTester.java:94)

	at us.kbase.sdk.ModuleBuilder$TestCommand.call(ModuleBuilder.java:445)

	at us.kbase.sdk.ModuleBuilder$TestCommand.call(ModuleBuilder.java:431)

	at picocli.CommandLine.executeUserObject(CommandLine.java:2031)
```

Fixed this bug and other potential bugs around NMS classes not being
fully accessible by making all methods, fields, and constructors
available for reflection.

Tested with the `kb_staging_exporter` app, which also has
`dropdown_option` in `spec.json`, by running `kb-sdk validate`.
@MrCreosote MrCreosote requested a review from ialarmedalien June 24, 2025 20:32
Comment on lines -259 to +265
"--enable-url-protocols=https,http,file",
"--enable-url-protocols=https,http",
Copy link
Member Author

Choose a reason for hiding this comment

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

file is enabled by default

Comment on lines -1056 to -1060
{
"name":"us.kbase.sdk.ModuleBuilder$ValidationArgs",
"allDeclaredFields":true,
"queryAllDeclaredMethods":true
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in a previous PR

Copy link

codecov bot commented Jun 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.04%. Comparing base (bd710aa) to head (8518b05).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #123   +/-   ##
=========================================
  Coverage     69.04%   69.04%           
  Complexity      650      650           
=========================================
  Files            45       45           
  Lines          3609     3609           
  Branches        669      669           
=========================================
  Hits           2492     2492           
  Misses          868      868           
  Partials        249      249           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

build.gradle Outdated
echo "Done. NOTE: Inspect the merged output carefully; the agent is better"
echo "than starting from scratch but is imperfect."
echo "When merging into src/main/resources/META-INF/native-image carefully"
echo "check that"

Choose a reason for hiding this comment

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

supremely picky, but if you're going to have a bulleted list, it'd be better to precede it with a colon, e.g.

echo "When merging into src/main/resources/META-INF/native-image carefully"
echo "check the following:"
echo ""

Given the likely audience size for this codebase, though, it doesn't really matter.

Isn't it nice to have a comment on your PR so that you know someone somewhere cares?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@MrCreosote MrCreosote merged commit 49a0172 into main Jun 24, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants