[Cases] Allow to add additional fields to IBM resilient connector#236144
[Cases] Allow to add additional fields to IBM resilient connector#236144janmonschke merged 36 commits intoelastic:mainfrom
Conversation
x-pack/platform/plugins/shared/cases/public/components/connectors/resilient/case_fields.tsx
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/cases/public/components/connectors/validate_json.ts
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/kibana-cases (Team:Cases) |
| if (action.schema) { | ||
| try { | ||
| action.schema.validate(subActionParams); | ||
| _subActionParams = action.schema.validate(subActionParams) as typeof subActionParams; |
There was a problem hiding this comment.
@cnasikas This is needed in order to automatically transform the additionalFields string to an object that we can run validations on.
There was a problem hiding this comment.
Thanks for fixing that. It makes sense to me.
|
Adding new parameters to a Connector typically involves creating an intermediate release, that just includes parameter schema changes. For more info: https://docs.elastic.dev/reops/developer-guide/best-practices-rules#upgrades-and-rollbacks . Note some of the docs only reference rule params, but connector params are affected here as well. Typically folks will create a PR with JUST the schema changes, and anything else required for them, and nothing else. Get that merged, and running on Serverless. After it's running on Serverless, the rest of the PR can be merged. So there's typically ~ one week delay between these ... |
|
@pmuellr Could you comment on the pieces of code I'd need to put into a separate PR? Is it just the changes in |
|
@pmuellr looking at the slides you linked 👍 If I put the UI behind a feature flag, we should be good as well, right? |
Correct. Though typically we don't modify "version" files like a
Correct. Just more work, as you'll have to deal with the changing the feature flag in a later release to make it the default. :-) |
| enableCaseSummary: schema.boolean({ defaultValue: false }), | ||
| }) | ||
| ), | ||
| resilient: schema.object({ |
| export const resilientFields = [ | ||
| import type { ResilientFieldMeta } from './schema'; | ||
|
|
||
| export const resilientFields: ResilientFieldMeta[] = [ |
x-pack/platform/plugins/shared/stack_connectors/server/connector_types/resilient/resilient.ts
Show resolved
Hide resolved
| givenValues, | ||
| null, | ||
| 2 | ||
| )}. Accepted values: ${valuesMeta.map((v) => `${v.value} (for "${v.label}")`)}` |
There was a problem hiding this comment.
Really nice error messaging here to get around the multi-select expectations. Thanks!
| } | ||
| case 'datetimepicker': | ||
| case 'datepicker': | ||
| return isNumber(value) ? { date: value } : {}; |
There was a problem hiding this comment.
Just confirming this is always expected to be number and doesn't need an additional isDate() conversion/check?
There was a problem hiding this comment.
Yep, this is supposed to be a number. Any other value will return a 400 from IBM Resilient
michaelolo24
left a comment
There was a problem hiding this comment.
Nice work, thank you for getting this done so promptly!
| read_only: schema.boolean(), | ||
| required: schema.nullable(schema.string()), | ||
| text: schema.string(), | ||
| internal: schema.boolean(), |
There was a problem hiding this comment.
I am not sure if older versions of Resilient respond with this field. Should we make it optional (nullable) just to be safe?
| } | ||
|
|
||
| // Custom fields need to be prefixed with 'properties.' | ||
| if (fieldMeta.prefix === 'properties') { |
There was a problem hiding this comment.
I would say not to make any assumptions about how users would put their custom fields. The IBM documentation is clear, so they should put the properties themselves. For example this is what they should put in the editor:
{
"state": 41,
"properties": {
"foo": "bar"
}
}
There was a problem hiding this comment.
imo, properties is an implementation detail and not necessarily known by the people that will use Kibana cases. I can change the logic to allow arbitrary prefixes if that sounds better?
| description?: { format: string; content: string }; | ||
| incident_type_ids?: Array<{ id: number }>; | ||
| severity_code?: { id: number }; | ||
| properties?: Record<string, unknown>; |
There was a problem hiding this comment.
We should remove this and add [unknown: string]: unknown, correct?
| if (field === 'incidentTypes') { | ||
| if (isArray(value)) { | ||
| return { ids: value.map((item) => Number(item)) }; | ||
| export function validateValues( |
There was a problem hiding this comment.
I am a bit concerned that we validate the values. What if an existing rule starts to fail because we started validating the fields?
There was a problem hiding this comment.
If an invalid value is supplied, the request to IBM will fail anyways. This is just a way to enhance the editing experience, since customers will have to add id(s) and not labels.
There was a problem hiding this comment.
Are we sure that all IBM resilient versions behave the same? Maybe we can fail at everything new but not at the old/existing fields?
There was a problem hiding this comment.
You mean only validate fields from the additionalFields?
There was a problem hiding this comment.
I was thinking that, yes, to be sure that we do not introduce a breaking change. Maybe I am too cautious. Wdyt?
There was a problem hiding this comment.
Sounds sensible to me. Mind if I do that in a follow-up PR?
| } | ||
|
|
||
| const fieldMeta = fieldsRecord[name]; | ||
| if (!fieldMeta) { |
There was a problem hiding this comment.
I am a bit concerned that we validate the values. What if an existing rule starts to fail because we started validating here?
There was a problem hiding this comment.
If there is no metadata for that field, we cannot determine the required shape for the update request, which is why we rely on it here.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
cc @janmonschke |
cnasikas
left a comment
There was a problem hiding this comment.
LGTM! I tested and it is working as expected. My main concerns are:
- Is throwing an error by validating the fields safe? I am concern about the old fields, not the new ones. Does all IBM resilient versions behave the same? Or was a case where some version did not throw an error for the old values?
- About the custom fields and prefixing the
properties, I do not think it is an implementation detail, because this is how the IBM Rest API docs tell you how to submit custom fields. Also, what if a custom field has the same key as a root field? Users will never be able to set both fields.
There was a problem hiding this comment.
Could you please add some test to cover the new functionality?
|
Pinging @elastic/response-ops (Team:ResponseOps) |
…astic#236144) ## Summary Allows to send additional properties via the IBM resilient connector <img width="1252" height="355" alt="Screenshot 2025-09-25 at 16 20 14" src="https://github.com/user-attachments/assets/78bbec79-22d2-47d5-8238-fcb14cfaf887" /> <img width="500" height="162" alt="Screenshot 2025-09-25 at 16 20 37" src="https://github.com/user-attachments/assets/cd615bdb-648d-48a1-ade0-8c8db1977d01" /> Fixes elastic#213890, Fixes elastic#213896 ### How to test - Set up the IBM resilient connector and enable it - Create a new case and add `{"test_text":"test"}` to `Additional fields` - Save the case and check that the field exists in IBM resilient - Go back to the case in Kibana, update the additional fields, push the update and check that the new value is present in IBM resilient **(Advanced)**: Try setting one of these values: ```json { "testing": "test", "test_text": "the text", "test_boolean": true, "test_number": 123, "test_date_picker": 2390748293, "test_date_time_picker": 2390748298, "test_select": 4, "test_multi_select": [1,3], "test_text_area": "" } ``` Try setting `test_select` or `test_multi_select`. They are values that are validated on the server. --------- Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
Summary
Allows to send additional properties via the IBM resilient connector
Fixes #213890, Fixes #213896
How to test
{"test_text":"test"}toAdditional fields(Advanced):
Try setting one of these values:
{ "testing": "test", "test_text": "the text", "test_boolean": true, "test_number": 123, "test_date_picker": 2390748293, "test_date_time_picker": 2390748298, "test_select": 4, "test_multi_select": [1,3], "test_text_area": "" }Try setting
test_selectortest_multi_select. They are values that are validated on the server.