Skip to content

[Response Ops][Connectors] New xpack.actions.email.services.enabled Kibana setting#223363

Merged
jcger merged 19 commits intoelastic:mainfrom
jcger:issue-220288-email-services-kbn-cfg
Jun 20, 2025
Merged

[Response Ops][Connectors] New xpack.actions.email.services.enabled Kibana setting#223363
jcger merged 19 commits intoelastic:mainfrom
jcger:issue-220288-email-services-kbn-cfg

Conversation

@jcger
Copy link
Contributor

@jcger jcger commented Jun 11, 2025

Summary

Closes #220288

Release note

New kibana setting xpack.actions.email.services.enabled to enable/disable email services for email connector.

@jcger jcger force-pushed the issue-220288-email-services-kbn-cfg branch from 1ac53e0 to 734e470 Compare June 13, 2025 09:58
@jcger jcger added Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// release_note:feature Makes this part of the condensed release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Jun 13, 2025
@jcger jcger marked this pull request as ready for review June 16, 2025 10:52
@jcger jcger requested review from a team as code owners June 16, 2025 10:52
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@jcger jcger marked this pull request as draft June 16, 2025 12:44
const disableServiceConfig = shouldDisableEmailConfiguration(service);
const { isLoading, getEmailServiceConfig } = useEmailConfig({ http, toasts });

useMount(() => {
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 after rendering, right? Shouldn't we fetch before rendering to prevent the UI from flashing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by "before rendering". I can only think of blocking the whole form or doing it server side. Server side isn't an option as we don't render server side, and blocking the whole form because of this seems like too much.

For more context: before my changes, we had a list of possible options, by default, it's set to empty. Once the user chooses an option, we fetch the linked data (host, port, and whether it's secure or not). But now, there is a chance that only one option is enabled and it would render as select with just one option. My changes are to set that only available service and it's linked data. useMount is just a useEffect with no dependencies in the dependency array. This way, it will only fetch once when the component is mounted in the DOM and yes, there will be a slight delay while loading the data linked to the enabled service.

}).not.toThrowError();
});

test('error when using a service that is not enabled', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is key, so I would extend these tests to also include does not throw when config is [*] and does not throw when fetching service enabled in config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

domain_allowlist: schema.maybe(schema.arrayOf(schema.string())),
services: schema.maybe(
schema.object({
enabled: schema.maybe(
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we set enabled: schema.maybe( but then schema.arrayOf has a default value. I think like this, the default value will never come into effect. We should probably pick one of the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did change/simplify this schema. The comment shouldn't apply anymore

{
validator: emptyField(i18n.SERVICE_REQUIRED),
{availableEmailServices.length === 1 ? (
<UseField
Copy link
Contributor

Choose a reason for hiding this comment

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

All tests changed in x-pack/platform/plugins/shared/stack_connectors/public/connector_types/email/email_connector.test.tsx expect the [*] scenario. We should also test when availableEmailServices.length === 1.

Maybe just checking that emailServiceInput exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcger jcger marked this pull request as ready for review June 17, 2025 10:45
Copy link
Contributor

@nastasha-solomon nastasha-solomon left a comment

Choose a reason for hiding this comment

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

Docs look good - thanks!

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Code LTGMT! I tested and I think there is a bug. In the UI I can see all services available even though I have configured the new setting. The backend throws as expected.

Screenshot 2025-06-18 at 3 18 20 PM

* 2.0.
*/

export const serviceParamValueToKbnSettingMap = {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for that!

Copy link
Member

Choose a reason for hiding this comment

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

Let's add a basic test for the new functionality (unless it has already been tested elsewhere; I haven't finished the review).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 9a957c3

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

The initial bug I reported seems to not be easily reproducible and probably it is related with how the config is cached. I found another bug. If I have an already configured connector with a service, I change the config to make this service unavailable and I try to save the connector I get an error even though it shows another valid service.

Screen.Recording.2025-06-19.at.12.31.31.PM.mov
validations: [
{
validator: emptyField(i18n.SERVICE_REQUIRED),
{availableEmailServices.length === 1 ? (
Copy link
Member

Choose a reason for hiding this comment

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

I think it is better if we do not introduce a separate field just for when the available services are. You could disable the selection (disabled: readOnly || isLoading || availableEmailServices.length <= 1,). I tested, and the result is visually the same. Nevertheless, I would say not to disable at all because users may want to change an already configured connector to the new valid service. Otherwise, they would have to delete that one and create a new one, meaning they would have to update all rules to use the new connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't check that the disabled select doesn't show the "expand" icon on the right. I will show a service that is not enabled, but the current service value of the connector. This means that if the user tries to update, they'll not be able to do so because the service is not enabled, and they'll have to update it.

I should still be disabled if only one service is enabled, even if it only applies to new connectors.

const disableServiceConfig = shouldDisableEmailConfiguration(service);
const { isLoading, getEmailServiceConfig } = useEmailConfig({ http, toasts });

useMount(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit confused why we want this extra API call. Should the useEffect achieve the same? The service is either what the user selected or what the connector is already configured. If the service is not part of the available services, and the connector is configured with such a service, we should probably not set any value or deselect the value. I think it is related to a bug I posted in my second review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The useEffect is triggered every time the user clicks on the select service component. I added useMount to automatically load the data linked to a service when there is only one service available. For example, if we just have amazon-ses, it will select that service and load the host, port and issecure fields automatically when rendering the form. Related to the bug you found, it shouldn't trigger if it's an already existing connector that has a service selected. Still useful for new connectors when only one service is enabled, though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't possible, at least not in a simple manner. Instead, the dropdown will have as options the enabled services. On update, it will render the enabled services and the currently stored service. If the user just updates the name, the BE will throw until the service is updated to an enabled option. The downside is that if only one service is enabled, we'll show a dropdown with just one option and the user will have to manually select that only option.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
stackConnectors 321 322 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
actions 335 336 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
stackConnectors 627.9KB 628.0KB +94.0B
triggersActionsUi 1.5MB 1.5MB +92.0B
total +186.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
actions 16.9KB 17.2KB +240.0B
stackConnectors 60.8KB 61.1KB +310.0B
triggersActionsUi 111.8KB 111.9KB +52.0B
total +602.0B
Unknown metric groups

API count

id before after diff
actions 341 342 +1

History

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

LGTM! I tested and is working as expected. The bugs I mentioned are not reproducible anymore.

@jcger jcger merged commit 411ab21 into elastic:main Jun 20, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15780864354

@jcger
Copy link
Contributor Author

jcger commented Jun 20, 2025

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jcger added a commit to jcger/kibana that referenced this pull request Jun 20, 2025
… Kibana setting (elastic#223363)

## Summary

Closes elastic#220288

## Release note
New kibana setting `xpack.actions.email.services.enabled` to
enable/disable email services for email connector.

(cherry picked from commit 411ab21)

# Conflicts:
#	docs/reference/configuration-reference/alerting-settings.md
#	docs/settings-gen/source/kibana-alert-action-settings.yml
jcger added a commit that referenced this pull request Jun 20, 2025
…nabled` Kibana setting (#223363) (#224710)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Response Ops][Connectors] New `xpack.actions.email.services.enabled`
Kibana setting (#223363)](#223363)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Julian
Gernun","email":"17549662+jcger@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-06-20T14:10:43Z","message":"[Response
Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana
setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release
note\nNew kibana setting `xpack.actions.email.services.enabled`
to\nenable/disable email services for email
connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:ResponseOps","release_note:feature","backport:version","v9.1.0","v8.19.0"],"title":"[Response
Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana
setting","number":223363,"url":"https://github.com/elastic/kibana/pull/223363","mergeCommit":{"message":"[Response
Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana
setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release
note\nNew kibana setting `xpack.actions.email.services.enabled`
to\nenable/disable email services for email
connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223363","number":223363,"mergeCommit":{"message":"[Response
Ops][Connectors] New `xpack.actions.email.services.enabled` Kibana
setting (#223363)\n\n## Summary\n\nCloses #220288\n\n## Release
note\nNew kibana setting `xpack.actions.email.services.enabled`
to\nenable/disable email services for email
connector.","sha":"411ab215a50c773fa535e48e1b7a8199176eefb0"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Jun 25, 2025
… Kibana setting (elastic#223363)

## Summary

Closes elastic#220288

## Release note
New kibana setting `xpack.actions.email.services.enabled` to
enable/disable email services for email connector.
jcger added a commit that referenced this pull request Jul 18, 2025
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 18, 2025
Bluefinger pushed a commit to Bluefinger/kibana that referenced this pull request Jul 22, 2025
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
florent-leborgne added a commit to florent-leborgne/kibana that referenced this pull request Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:feature Makes this part of the condensed release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.19.0 v9.1.0

9 participants