Skip to content

[Fleet] Fix dupplicate ids when copying an integration policy or an agent policy#250971

Merged
nchaulet merged 3 commits intomainfrom
fix-copy-integration-ids
Jan 30, 2026
Merged

[Fleet] Fix dupplicate ids when copying an integration policy or an agent policy#250971
nchaulet merged 3 commits intomainfrom
fix-copy-integration-ids

Conversation

@nchaulet
Copy link
Copy Markdown
Member

@nchaulet nchaulet commented Jan 29, 2026

Summary

Related to #249592

The newly introducing copy an integration is copying input/streams id creating duplicate ids, that PR fix that by removing the ids when creating the policy.

We found similar issue for copied package policies from copy agent policy feature #250978, that PR fix it too

Tests

I updated the types, to a type NewPackagePolicy that would have catch that issue.

You can test this by copying a package policy and verifying the resulting ids are different.

Screenshot 2026-01-29 at 2 37 10 PM Screenshot 2026-01-29 at 2 38 13 PM Screenshot 2026-01-29 at 2 38 57 PM

@nchaulet nchaulet self-assigned this Jan 29, 2026
@nchaulet nchaulet requested a review from a team as a code owner January 29, 2026 19:36
@nchaulet nchaulet added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Fleet Team label for Observability Data Collection Fleet team labels Jan 29, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet nchaulet changed the title [Fleet] Fix dupplicate ids when copying an integration policy [Fleet] Fix dupplicate ids when copying an integration policy or an agent policy Jan 30, 2026
@nchaulet nchaulet added backport:version Backport to applied version labels v9.2.5 v9.3.1 and removed backport:skip This PR does not require backporting labels Jan 30, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #84 / Fleet tasks Automatic agent upgrades should take agents on target version into account

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1393 1394 +1

Async chunks

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

id before after diff
fleet 2.2MB 2.2MB +239.0B

History

cc @nchaulet

Copy link
Copy Markdown
Contributor

@Supplementing Supplementing left a comment

Choose a reason for hiding this comment

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

One small question, but otherwise, LGTM 🚀

...copyPackagePolicy(packagePolicy),
name: await incrementPackagePolicyCopyName(soClient, packagePolicy.name),
};
} as NewPackagePolicy & { id: undefined };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sniff test, should we use a partial or consider updating the type so we dont have to do this cast here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call, I consider updating the type, but it started to be a lot of changes around and as it's a bug fix that will be back-ported it seems it's adding a lot to manage.

@nchaulet nchaulet merged commit cdd9192 into main Jan 30, 2026
24 checks passed
@nchaulet nchaulet deleted the fix-copy-integration-ids branch January 30, 2026 17:59
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.2, 9.3

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.2 Backport failed because of merge conflicts
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 250971

Questions ?

Please refer to the Backport tool documentation

@nchaulet
Copy link
Copy Markdown
Member Author

💚 All backports created successfully

Status Branch Result
9.3
9.2

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

Questions ?

Please refer to the Backport tool documentation

nchaulet added a commit to nchaulet/kibana that referenced this pull request Jan 30, 2026
…gent policy (elastic#250971)

(cherry picked from commit cdd9192)

# Conflicts:
#	x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/copy_package_policy_page/index.tsx
#	x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/components/layout.tsx
#	x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/form.tsx
#	x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/types.ts
nchaulet added a commit that referenced this pull request Jan 30, 2026
…r an agent policy (#250971) (#251127)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Fleet] Fix dupplicate ids when copying an integration policy or an
agent policy (#250971)](#250971)

<!--- Backport version: 10.2.0 -->

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

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2026-01-30T17:59:55Z","message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.4.0","v9.2.5","v9.3.1"],"title":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent
policy","number":250971,"url":"https://github.com/elastic/kibana/pull/250971","mergeCommit":{"message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2"}},"sourceBranch":"main","suggestedTargetBranches":["9.2","9.3"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/250971","number":250971,"mergeCommit":{"message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
nchaulet added a commit that referenced this pull request Jan 30, 2026
…r an agent policy (#250971) (#251128)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Fleet] Fix dupplicate ids when copying an integration policy or an
agent policy (#250971)](#250971)

<!--- Backport version: 10.2.0 -->

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

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2026-01-30T17:59:55Z","message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.4.0","v9.2.5","v9.3.1"],"title":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent
policy","number":250971,"url":"https://github.com/elastic/kibana/pull/250971","mergeCommit":{"message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2"}},"sourceBranch":"main","suggestedTargetBranches":["9.2","9.3"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/250971","number":250971,"mergeCommit":{"message":"[Fleet]
Fix dupplicate ids when copying an integration policy or an agent policy
(#250971)","sha":"cdd919287fc5c989c3ac74a18ee2ff5c79d6bde2"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
hannahbrooks pushed a commit to hannahbrooks/kibana that referenced this pull request Jan 30, 2026
mbondyra added a commit to mbondyra/kibana that referenced this pull request Feb 2, 2026
…iew_cps

* commit '32efd9b2fb078ade51073fd2d0068bc74c029d6b': (49 commits)
  [Security Solution] Rules exceptions subfeatures (elastic#245722)
  [BK] Upgrade axios (elastic#251150)
  Fix AI Connector form fields resetting to default value when cleared by user (elastic#251095)
  deduplicate otel dependencies (elastic#250841)
  Adds initial agents.md file (elastic#250833)
  [index management] Faster index list loading (elastic#246276)
  skip failing test suite (elastic#251086)
  skip failing test suite (elastic#251048)
  [Security Solutions] Trial Companion - adjust UX design (elastic#250910)
  [Traces][Discover] Prevent flyout remount when switching document types in Trace Waterfall (elastic#250406)
  [DOCS][Cases][9.4 & Serverless]: Doc new `Maximum amount of cases to open` setting for case action (elastic#250993)
  [Discover][Traces] Explore trace.id from logs in Discover (elastic#249632)
  Remove ! from SOs docs link (elastic#251097)
  [ML] Maps: Add telemetry events for file uploads (elastic#247543)
  [Fleet] Fix dupplicate ids when copying an integration policy or an agent policy (elastic#250971)
  [Dashboards as Code] Add snake case object keys util (elastic#250962)
  [Core] Remove URL Overflow & Deprecate `storeInSessionStorage` setting (elastic#242972)
  [One Workflow] fix: Fix Variable Retrieval in Workflow Execution Engine (elastic#250852)
  Rework Elastic Managed LLMs page (elastic#251069)
  [Lens powered by ES|QL] Update Switch to Query mode modal warning message (elastic#251051)
  ...
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:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.2.5 v9.3.0 v9.3.1 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants