Skip to content

Return useful data from /pluginManager/api/json by default#26351

Open
himanshu748 wants to merge 4 commits intojenkinsci:masterfrom
himanshu748:fix/JENKINS-27993-pluginmanager-api
Open

Return useful data from /pluginManager/api/json by default#26351
himanshu748 wants to merge 4 commits intojenkinsci:masterfrom
himanshu748:fix/JENKINS-27993-pluginmanager-api

Conversation

@himanshu748
Copy link

@himanshu748 himanshu748 commented Feb 22, 2026

  • Increase @Exported visibility to 2 for key PluginWrapper properties so they appear at default depth under PluginManager.plugins.
  • Add @Exported to PluginWrapper#getDisplayName() as the non-deprecated alternative to getLongName().
  • Add an integration test validating that /pluginManager/api/json returns non-empty plugin objects and expected fields.

Copilot AI review requested due to automatic review settings February 22, 2026 10:44
@welcome
Copy link

welcome bot commented Feb 22, 2026

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@comment-ops-bot comment-ops-bot bot added rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted labels Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes JENKINS-27993 by making /pluginManager/api/json return meaningful PluginWrapper details at the default API depth, instead of {} entries, by increasing export visibility for key properties.

Changes:

  • Increase @Exported visibility to 2 for key PluginWrapper properties so they appear at default depth under PluginManager.plugins.
  • Add @Exported to PluginWrapper#getDisplayName() as the non-deprecated alternative to getLongName().
  • Add an integration test validating that /pluginManager/api/json returns non-empty plugin objects and expected fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/main/java/hudson/PluginWrapper.java Raises export visibility for commonly needed plugin metadata (and exports displayName) so nested plugin entries are populated at default depth.
test/src/test/java/hudson/PluginManagerTest.java Adds a regression test for /pluginManager/api/json ensuring plugin details are present without specifying depth.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +565 to +572
// Verify key properties are present at default depth (visibility = 2)
assertNotNull(htmlPublisher.optString("shortName", null), "shortName should be exported at default depth");
assertNotNull(htmlPublisher.optString("version", null), "version should be exported at default depth");
assertNotNull(htmlPublisher.optString("longName", null), "longName should be exported at default depth");
assertNotNull(htmlPublisher.optString("displayName", null), "displayName should be exported at default depth");
assertTrue(htmlPublisher.has("active"), "active should be exported at default depth");
assertTrue(htmlPublisher.has("enabled"), "enabled should be exported at default depth");
assertTrue(htmlPublisher.has("hasUpdate"), "hasUpdate should be exported at default depth");
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The PR description says the new test verifies that the response includes url, but this test currently never asserts that url is present. Either add an assertion for url (and, if needed for stability, set up update site data like prevalidateConfig() does with /plugins/htmlpublisher-update-center.json) or update the PR description to match what’s actually being tested.

Copilot uses AI. Check for mistakes.
@MarkEWaite MarkEWaite changed the title [JENKINS-27993] Make /pluginManager/api/json return useful plugin data at default depth Return useful data from /pluginManager/api/json by default Feb 22, 2026
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request and thanks for including a test of the changes.

There are two changes that I believe are needed.

Copy link
Member

@daniel-beck daniel-beck left a comment

Choose a reason for hiding this comment

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

Do not change lines unrelated to your pull request.

@himanshu748 himanshu748 force-pushed the fix/JENKINS-27993-pluginmanager-api branch 2 times, most recently from c25d2e1 to 4db6bed Compare February 23, 2026 09:37
…ties

The /pluginManager/api/json endpoint returned empty objects for each
plugin because all @exported properties had default visibility (1),
which is not rendered when nested inside PluginManager at the default
API depth.

Increase visibility to 2 on key properties (shortName, version,
longName, displayName, url, active, enabled, hasUpdate) so they
appear at the default depth. Also add @exported to getDisplayName()
as the non-deprecated replacement for getLongName().
@himanshu748 himanshu748 force-pushed the fix/JENKINS-27993-pluginmanager-api branch from 4db6bed to 9193501 Compare February 23, 2026 09:47
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Please don't force push changes. It breaks the link between pull request comments and the commits. We will squash merge at the end, so flawed steps along the way are not an issue.

Please remove the @Exported(visibility = 2) change from getLongName or explain why you must retain it.

- Remove @exported from deprecated properties lengthName & backupVersion
- Fix Issue link in PluginManagerTest from JENKINS-27993 to issues/21047
Copy link
Author

@himanshu748 himanshu748 left a comment

Choose a reason for hiding this comment

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

Thanks for the review. I have removed @Exported(visibility = 2) from the deprecated getLongName() method, fixed the issue link in the test to point to GitHub, and updated the PR description to accurately reflect that url is not being asserted in this test since it requires update site metadata. Pushed without a force push.


/**
* Makes sure that thread context classloader isn't used by {@link UberClassLoader}, or else
* Makes sure that thread context classloader isn't used by
Copy link
Member

Choose a reason for hiding this comment

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

No reformatting please. This applies to most changed lines in this file.

Copy link
Author

Choose a reason for hiding this comment

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

Apologies for the noise. All unrelated formatting changes have been reverted in ca4cdf2. The test file diff is now purely additive (+30/-0) — only the new test method, zero reformatting.

Reverts all auto-formatter whitespace/reformatting changes that were
unrelated to this PR. Only retains the new test method for
/pluginManager/api/json.
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Thanks. Change looks good to me

@MarkEWaite MarkEWaite added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted squash-merge-me Unclean or useless commit history, should be merged only with squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants