Skip to content
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

feat(api): Centralize the logic to read feature flag values (#29900) #29904

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spbolton
Copy link
Contributor

@spbolton spbolton commented Sep 6, 2024

Proposed Changes

  • Add alternative filtering and selection to /v1/configuration/config endpoint
  • either original "keys" html parameter can be used or the following new optional parameters contains, startsWith, endsWith and caseSensitive (default false)
  • When case insensitive matching is enabled which is the default underscores are replaced with "." for matching the original key is returned

Things to think about

  • Not all properties keys in use in the system may not be loaded from the environment or config files and will only be returned if they have been queried.
  • This exposes inconsistencies in the config property nameing that we should separately address but is still useful now.
  • We need to be aware of whether this introduces any security risks we need to tie down.
  • For a base system we are probably ok without paging or restricting the results returned, but we may need to think about this.
  • The results are all returned as string values, this should be ok leaving any convesion to the client but we need to be aware of this and confirm all types are being returned in a way that can be processed
  • We will need to confirm the performance and how many keys we may be dealing with
  • If there are no security limitations of this endpoint and the original "keys" property works as before we would be safe to merge this and then follow up with any UI changes to make use of this

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

This PR resolves #29900 (Centralize the logic to read feature flag values).

Screenshots

Original Updated
** original screenshot ** ** updated screenshot **

@spbolton spbolton linked an issue Sep 6, 2024 that may be closed by this pull request
@spbolton spbolton marked this pull request as draft September 6, 2024 13:05
@nollymar
Copy link
Contributor

nollymar commented Sep 6, 2024

Before merging this PR, I want to make sure that we have a real need to implement the filtering. Have we identified a real need from FE, support, etc?
If so, my only suggestion would to be to include a postman test.


if (keysQuery != null && !keysQuery.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think StringUtils.isSet does this


if (keysQuery != null && !keysQuery.isEmpty()) {
// Old behavior when keys parameter is provided
final String[] keys = StringUtils.splitByCommas(keysQuery);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be perform with a Stream such as

Stream.of(key).map(this::removePrefix).filter....

resultMap.put(keyWithoutPrefix, recoveryFromConfig(key));
}
}
} else {
// New filtering behavior

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this should be in another place

Copy link
Contributor

@jdotcms jdotcms left a comment

Choose a reason for hiding this comment

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

I have left some comments but in general is a good improve for the configs

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.

Centralize the logic to read feature flag values
3 participants