Skip to content

Conversation

@Jarvx
Copy link

@Jarvx Jarvx commented Oct 21, 2025

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.keys to 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.

./gradlew :test-suite-kotlin-ksp:test

@Jarvx
Copy link
Author

Jarvx commented Oct 24, 2025

I'll close this pr first because the CI fails.

@Jarvx Jarvx closed this Oct 24, 2025
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

class EnvEndpointKeysConfigTest {
Copy link
Contributor

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) {
Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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

@Jarvx
Copy link
Author

Jarvx commented Oct 24, 2025

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.

@Jarvx Jarvx reopened this Oct 24, 2025
@Jarvx Jarvx changed the title Fix 11799: binding a list to endpoints.env.keys to ensure only 'activeEnvironments' remains. [GenAI] Fix 11799: binding a list to endpoints.env.keys to ensure only 'activeEnvironments' remains. Oct 24, 2025
@Jarvx
Copy link
Author

Jarvx commented Oct 31, 2025

I have pushed a new fix and test scripts. Hope this can be an improvement than the first cut.

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