[integration automatic-import] Small bugfixes (#188778)

This PR fixes two bugs that were causing failures leading to recursion
timeouts when generating integrations:

1) Small prompt tweak to the related prompt instruction the LLM to
include the if condition inside the processor
2) Followup fix to https://github.com/elastic/kibana/pull/187643 to also
include a field null check on the processor
This commit is contained in:
Kylie Meli 2024-07-19 16:15:51 -04:00 committed by GitHub
parent 5adf5be1c8
commit c27adf11da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View file

@ -91,7 +91,7 @@ export const ecsMappingExpectedResults = {
description: 'Ensures the date processor does not receive an array value.',
lang: 'painless',
source:
'if (ctx.mysql_enterprise.audit.timestamp instanceof ArrayList){\n ctx.mysql_enterprise.audit.timestamp = ctx.mysql_enterprise.audit.timestamp[0];\n}\n',
'if (ctx.mysql_enterprise?.audit?.timestamp != null &&\n ctx.mysql_enterprise.audit.timestamp instanceof ArrayList){\n ctx.mysql_enterprise.audit.timestamp = ctx.mysql_enterprise.audit.timestamp[0];\n}\n',
tag: 'script_convert_array_to_string',
},
},

View file

@ -37,6 +37,7 @@ export const RELATED_MAIN_PROMPT = ChatPromptTemplate.fromMessages([
- You can add as many append processors you need to cover all the fields that you detected.
- If conditions should always use a ? character when accessing nested fields, in case the field might not always be available, see example processors above.
- When an if condition is not needed the argument should not be used for the processor object.
- The if condition must be located within the processor object.
- Do not respond with anything except the array of processors as a valid JSON objects enclosed with 3 backticks (\`), see example response below.
</guidelines>

View file

@ -32,7 +32,8 @@ processors:
tag: script_convert_array_to_string
lang: painless
{% raw %}source: |
if (ctx.{% endraw %}{{ value.field }}{% raw %} instanceof ArrayList){
if (ctx.{% endraw %}{{ value.field.replaceAll('.', '?.') }}{% raw %} != null &&
ctx.{% endraw %}{{ value.field }}{% raw %} instanceof ArrayList){
ctx.{% endraw %}{{ value.field }}{% raw %} = ctx.{% endraw %}{{ value.field }}{% raw %}[0];
}{% endraw %}
- {{ key }}: