fix(appsec): restore settings when ASM_FEATURES changes #22053
Codeowners resolved as
Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.
ddtrace/appsec/_remoteconfiguration.py @DataDog/asm-python
releasenotes/notes/fix-appsec-rc-auto-user-instrum-mode-removal-28074e245a143804.yaml @DataDog/apm-python
tests/appsec/appsec/test_remoteconfiguration.py @DataDog/asm-python
Dependency direction analysis
⚠️ Existing dependency direction violations
There are 22 dependency direction violations that already exist on the base branch and have not been changed by this PR.
<details><summary>Show existing violations (showing 5 of 22 highest severity)</summary>
ddtrace.internal.tracemethods -×-> ddtrace.trace (internal-core -> product:tracing, score=103)
ddtrace.llmobs._integrations.bedrock_agents -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace (product:llmobs -> product:tracing, score=101)
ddtrace.internal.span_bus -×-> ddtrace._trace.span (internal-core -> product:tracing, score=35)
ddtrace.llmobs._llmobs -×-> ddtrace._trace.span (product:llmobs -> product:tracing, score=33)
</details>
To see all violations, download thelayers-base.jsonandlayers-pr.jsonartifacts from this CI job and run:
> uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json >
<a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3A2862e9f5d1310b3b9ca4759b92aa1fbcd82f21df&referrer=pr-comment&start=1795533256000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture></a> <a target='_blank' href='https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest+%40git.commit.sha%3A6d25acd25677399911c025c65ef21d7fb1ffd335&referrer=pr-comment&start=1795533256000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok-light.svg" alt="Tests" align="center" /></picture></a>
<details><summary><b>🎉 All green!</b></summary>
🧪 All tests passed
❄️ No new flaky tests detected
</details>
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 2862e9f | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RkLXRyYWNlLXB5LzIyMDUz?referrer=pr-comment">View more details</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
Benchmarks
Benchmark execution time: 2026-11-24 16:18:02
Comparing candidate commit 2862e9f5d1310b3b9ca4759b92aa1fbcd82f21df in PR branch dd/reset-auto-user-instrum-on-asm-features-removal with baseline commit b801aa3dea9c3e34ee3b72e2fe502f40a0d6b837 in branch main.
Found 0 performance improvements and 0 performance regressions! Performance is the same for 589 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.
<details>
<summary><h3>Explanation</h3></summary>
This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:
🟩 = significantly better candidate vs. baseline
🟥 = significantly worse candidate vs. baseline
We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.
If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.
Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.
<details>
<summary><h4>More details about the CI and significant changes</h4></summary>
You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.
CIs of the difference of means are often centered around 0%, because often changes are not that big:
---------------------------------(------|---^--------)-------------------------------->
-0.6% 0% 0.3% +1.2%
| | |
lower bound of the CI --' | |
sample mean (center of the CI) -------------' |
upper bound of the CI ----------------------'
As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).
For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:
----------------------------------------|---------|---(---------^---------)---------->
0% 1% 1.3% 2.2% 3.1%
| | | |
significant impact threshold --------------' | | |
lower bound of CI --------------' | |
sample mean (center of the CI) --------------------------' |
upper bound of CI ----------------------------------'
</details>
</details>
<details>
<summary><h3>Unstable benchmarks</h3></summary>
These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.
scenario:coreapiscenario-context_with_data_listeners
execution_time [-641.896ns; +771.113ns] or [-5.976%; +7.179%]scenario:coreapiscenario-core_dispatch_1_listener
execution_time [-37.828ns; +37.316ns] or [-5.900%; +5.820%]scenario:coreapiscenario-core_dispatch_50_listeners
execution_time [-1978.072ns; +1677.699ns] or [-9.870%; +8.371%]scenario:coreapiscenario-core_dispatch_exception_listeners
execution_time [-1415.852ns; +2140.752ns] or [-7.330%; +11.083%]scenario:coreapiscenario-core_dispatch_listeners
execution_time [-341.364ns; +388.396ns] or [-7.987%; +9.087%]scenario:coreapiscenario-core_dispatch_no_args_listeners
execution_time [-148.686ns; +289.434ns] or [-5.596%; +10.894%]scenario:coreapiscenario-core_dispatch_with_results_1_listener
execution_time [-62.364ns; +117.375ns] or [-4.580%; +8.620%]scenario:coreapiscenario-core_dispatch_with_results_50_listeners
execution_time [-4039.618ns; +4851.614ns] or [-8.359%; +10.040%]scenario:coreapiscenario-core_dispatch_with_results_listeners
execution_time [-893.961ns; +946.611ns] or [-8.674%; +9.185%]scenario:packagesupdateimporteddependencies-import_many_stdlib_cached
execution_time [-33.333µs; +44.886µs] or [-5.794%; +7.802%]</details>
<details>
<summary><h3>Known flaky benchmarks</h3></summary>
These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.
Known flaky benchmarks without significant changes:
</details>
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"2862e9f5d1310b3b9ca4759b92aa1fbcd82f21df","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":"2862e9f5d1310b3b9ca4759b92aa1fbcd82f21df","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} -->
<!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"2862e9f5d1310b3b9ca4759b92aa1fbcd82f21df","mergeGateEnabled":false,"pullRequestNumber":22053,"repository":"DataDog/dd-trace-py","status":"completed"} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-24T15:45:27.880419Z">2026-11-24T15:45:27.880419Z</relative-time> | 2862e9f | New commits |
| 🔒 Security Review | ✅ Completed <relative-time datetime="2026-11-24T15:48:45.311058Z">2026-11-24T15:48:45.311058Z</relative-time> | 2862e9f | New commits |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<details>
<summary>More details</summary>
Source inspection supports correct fallback across partial replacements, overlapping configurations, and combined removals, including restoration of the local user-event mode after the final override disappears.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 2161759</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=be973525-9226-48d8-ac9a-a39517a4fd33 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:55846ab50e0266df6e87a5be8a1427825bbeaadc64f785734e6e892adf9d3974:bundle -->
Approved these changes.
/merge
<!-- "FeedbackWorkflowId":"17d870e2-00bd-49fb-98b8-946f17ea63cc_39" -->
View all feedbacks in Devflow UI.
2026-11-24 16:19:07 UTC :information_source: Start processing command /merge
---2026-11-24 16:19:21 UTC :information_source: MergeQueue: Pull request is not mergeable yet
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
/code blockers to see what is blocking it./remove to cancel it.---2026-11-24 16:29:08 UTC :information_source: MergeQueue: merge request added to the queue
The expected merge time in main is approximately 1h (p90).
---2026-11-24 17:17:31 UTC :information_source: MergeQueue: This merge request was merged
avara1986
florentinl
Description
Removing a remote configuration that set both App and API Protection activation and the automatic user event collection mode reset only activation. Replacing the same configuration with one that omitted a setting could also leave the old value in effect.
Treat each
ASM_FEATURESupdate as a full replacement for its path. For each affected setting, use the most recently delivered configuration that still specifies it. Reset the setting only when no remaining configuration supplies it.Customer impact
Removing a remote override no longer leaves automatic user event collection in the wrong mode or clears a setting still supplied by another configuration. When the last mode override is removed, the locally configured mode applies again.
Testing
scripts/lint checksand focused type checks passed.Risks
The change only affects how the AppSec remote configuration callback resolves activation and automatic user event collection settings. It does not change the remote configuration protocol, product lifecycle, or fork handling.