-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Actions] makes savedObjectId field optional #79186
[Actions] makes savedObjectId field optional #79186
Conversation
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
Hi @gchaps , It isn't really in use yet, but longer term it would be used to link back to the Alert (or other Saved Object) which fired the Action. In the context of Alerts we don't show this label, as it is automatically populated, so this field will only appear in situations where we don't know what Saved Object might be referenced here. |
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.
LGTM
How about using a simple label: Object ID And something along these lines in a tooltip: The API uses this ID to call the service. |
Will do, thanks :) |
* master: (128 commits) add core-js production dependency (elastic#79395) Add support for sharing saved objects to all spaces (elastic#76132) [Alerting UI] Display a banner to users when some alerts have failures, added alert statuses column and filters (elastic#79038) load js-yaml lazily (elastic#79092) skip flaky suite (elastic#77278) Fix agentPolicyUpdateEventHandler() to use app context soClient for creation of actions (elastic#79341) [Security Solution] Untitled Timeline created when first action is to add note (elastic#78988) [Security Solutions][Detection Engine] Updates the edit rules page to:wq! only have what is selected for editing (elastic#79233) Cleanup yarn.lock from duplicates (elastic#66617) [kbn/optimizer] implement more efficient auto transpilation for node (elastic#79052) [Ingest Manager] Rename Fleet setup and requirement, Fleet => Central… (elastic#79291) [core/server/plugins] don't run discovery in dev server parent process (take 2) (elastic#79358) [babel/register] remove from build (take 2) (elastic#79379) [Security Solution] Changes rules table tag display (elastic#77102) define integrationTestRoot in config file and use to define screensho… (elastic#79247) Revert "[babel/register] remove from build (elastic#79176)" skip flaky suite (elastic#75241) [Uptime] Synthetics UI (elastic#77960) [Security Solution] [Detections] Only display actions options if user has "read" privileges (elastic#78812) [babel/register] remove from build (elastic#79176) ...
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.
Looks good!
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.
LGTM, but it seems like the nullable on resilient is missing, and there is some extraneous code here (re: action execution results)
unsafeResult && | ||
typeof unsafeResult === 'object' && | ||
unsafeResult?.actionId === 'string' && | ||
(unsafeResult?.status === 'ok' || unsafeResult?.status === 'error') |
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 seems fragile, in terms of if we ever change the status
field to have values other than ok
| error
. I think doing a typeof ... === 'string'
is probably fine here as well.
Oh, and just noticed the line above is probably intended to be the following (looks like it's missing typeof
)
typeof unsafeResult?.actionId === 'string' &&
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.
Yeah, it's definitely fragile - but I don't think there's another way around this as we do this in a catch
and Typescript has no type checking on error handling. One of my main gripes with error throwing.
Do you have any advice for another way to do this?
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.
It seems like the lines
unsafeResult?.actionId === 'string' &&
(unsafeResult?.status === 'ok' || unsafeResult?.status === 'error')
should be
typeof unsafeResult?.actionId === 'string' &&
typeof unsafeResult?.status === 'string'
@@ -34,7 +34,7 @@ export const ExecutorSubActionSchema = schema.oneOf([ | |||
]); | |||
|
|||
export const ExecutorSubActionPushParamsSchema = schema.object({ | |||
savedObjectId: schema.string(), | |||
savedObjectId: schema.nullable(schema.string()), |
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.
I'm curious if this includes the SO type and spaceId. We can of course assume the spaceId for now. Is the type encoded in the string, or assumed to be alert
? Could use a comment describing it.
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.
I'm not touching the behaviour in this PR, just focusing on decoupling it from Alerting so that it's technically possible to execute.
It is in theory assuming this is an Alert, but apparently it isn't actually being used properly yet, so we decided to keep it because we already have this being sent to these services, but once we try to actually use these to generate URLs we'll definitely need to add the type.
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.
LOL, github seems to have the diff confused here 🤔
@@ -32,7 +32,10 @@ import { updateActionConnector, executeAction } from '../../lib/action_connector | |||
import { hasSaveActionsCapability } from '../../lib/capabilities'; | |||
import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; | |||
import { PLUGIN } from '../../constants/plugin'; | |||
import { ActionTypeExecutorResult } from '../../../../../actions/common'; | |||
import { |
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.
Do the changes to execute, including the following files, belong in this PR? Seems like they should be in a separate one.
x-pack/plugins/actions/common/types.ts
x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts
,
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.
They belong here in that without them it becomes impossible to correctly display the error in this PR.
It is addressing a broader problem that I identified while working on this. 🤷
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.
Gotcha, thx!
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.
with the latest commits, LGTM
@@ -32,7 +32,10 @@ import { updateActionConnector, executeAction } from '../../lib/action_connector | |||
import { hasSaveActionsCapability } from '../../lib/capabilities'; | |||
import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; | |||
import { PLUGIN } from '../../constants/plugin'; | |||
import { ActionTypeExecutorResult } from '../../../../../actions/common'; | |||
import { |
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.
Gotcha, thx!
@gmmorris Maybe this tweak to the tooltip: JIRA will associate this action with the ID of a Kibana saved object. |
Very last minute change is in 👍 😄 Thanks @gchaps |
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
This PR makes the `savedObjectId` parameter optional in the Jira, ServiceNow and IBM Resilient Connectors. This allows them to execute without this field outside of Alerts, as it is currently populated using the `alertId` which isn't available in other places. Additionally this adds an optional field in the `Params` Components for all three of the connectors, which allows users to provide a value for the `savedObjectId` field if the so wish.
This PR makes the `savedObjectId` parameter optional in the Jira, ServiceNow and IBM Resilient Connectors. This allows them to execute without this field outside of Alerts, as it is currently populated using the `alertId` which isn't available in other places. Additionally this adds an optional field in the `Params` Components for all three of the connectors, which allows users to provide a value for the `savedObjectId` field if the so wish.
Summary
closes #79010
This PR makes the
savedObjectId
parameter optional in the Jira, ServiceNow and IBM Resilient Connectors.This allows them to execute without this field outside of Alerts, as it is currently populated using the
alertId
which isn't available in other places.Additionally this adds an optional field in the
Params
Components for all three of the connectors, which allows users to provide a value for thesavedObjectId
field if the so wish.Checklist
Delete any items that are not applicable to this PR.
For maintainers