-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[GenAI] Fix 11799: binding a list to endpoints.env.keys to ensure only 'activeEnvironments' remains. #12145
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
base: 4.10.x
Are you sure you want to change the base?
Conversation
|
I'll close this pr first because the CI fails. |
| import org.junit.jupiter.api.Assertions.* | ||
| import org.junit.jupiter.api.Test | ||
|
|
||
| class EnvEndpointKeysConfigTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be in Java or Groovy like all our tests and be placed in io.micronaut.management.endpoint since that is the functionality under test
| * | ||
| * @param keys The list of sections. If an empty list is provided, no sections will be displayed. | ||
| */ | ||
| public void setKeys(List<String> keys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fix seems unnecessary and the functionality already implemented by setActiveKeys so it appears this is just a documentation issue and no fix is needed.
| props["micronaut.server.port"] = 0 | ||
|
|
||
| server = ApplicationContext.run(EmbeddedServer::class.java, props) | ||
| client = HttpClient.create(server!!.url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the client here is never closed and will leak resources
| "io.micronaut.management.endpoint.env.EnvironmentController" | ||
| ) | ||
|
|
||
| for (className in candidateClassNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very weird logic, why is reflection being used?
| import org.junit.jupiter.api.Assertions.* | ||
| import org.junit.jupiter.api.Test | ||
|
|
||
| class EnvEndpointKeysConfigTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests in EnvironmentEndpointSpec already test this functionality in a better way, so this test is largely useless
|
I do not have the permission to add a label. So I'll just add a tag in the title to indicate this PR has used AI. |
…tKeys() and setKeys(List<String>).
|
I have pushed a new fix and test scripts. Hope this can be an improvement than the first cut. |
Issue: #11799
Bug description
To allow selective fields in env endpoint via endpoints.env.keys configuration
Solution
What the test file do is configuring the env endpoint via
endpoints.env.keysto only include 'activeEnvironments' and exclude 'packages' and 'propertySources'. On the original code, the test failed because the implementation only honored endpoints.env.active-keys, not the new endpoints.env.keys alias.The patch adds
getKeys()/setKeys(List<String>)as aliases to the existing activeKeys property, allowing Micronaut's configuration binding to map endpoints.env.keys to the same underlying list. This maintains backward compatibility with endpoints.env.active-keys and satisfies the new configuration option.Steps to reproduce
Please use this command to observe the output from provided test case.