[9.3] [Security GenAI] Use stable IDs for Security AI Prompt saved object filenames (#265301)#265823
Merged
kibanamachine merged 2 commits intoelastic:9.3from Apr 30, 2026
Merged
Conversation
…ilenames (elastic#265301) ## Summary Resolves elastic#237178. The `generate_security_ai_prompts_script.ts` script previously generated saved object filenames using a random UUID on every invocation (e.g. `security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`). This made PR reviews noisy and required a `rm ./*.json` step when copying files into the integration package. This PR replaces `uuidv4()` with a deterministic `generateStableId` function that builds the ID from `promptGroupId`, `promptId`, and optionally `provider` and `model` — all lowercased. Example stable filename: ``` security_ai_prompts-aiassistant-systemprompt-openai.json ``` ### Changes - **Script**: replaced `uuidv4()` with `generateStableId(prompt)` that derives a stable, lowercase ID from the prompt's identifying fields. Removed `uuid` import. - **Tests**: added 13 Jest unit tests for `generateStableId`, `generateSavedObject`, and `generateSavedObjects`. - **README**: removed the `rm ./*.json` step from the developer update flow — with stable filenames, `cp` overwrites files in place without needing to clear them first. ### Migration note The first time the script runs after this change, the integration repo (`elastic/integrations`) will still contain the old UUID-named files. A one-time `rm ./*.json` followed by `cp` in that repo is needed to fully replace them with stable-named files. After that, the `rm` step is no longer required. ## Test plan - [x] `node scripts/jest x-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts` — 13 tests pass - [x] `node scripts/check_changes.ts` — lint and pre-commit checks pass - [x] Run `yarn generate-security-ai-prompts` in `x-pack/solutions/security/plugins/elastic_assistant` and confirm output filenames are stable across multiple invocations --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 6f23495)
3 tasks
Member
|
@elasticmachine merge upstream |
Contributor
Author
💚 Build Succeeded
Metrics [docs]
History
cc @KDKHD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.3:Questions ?
Please refer to the Backport tool documentation