Skip to content

[9.4] Gracefully handle deprecated telemetry config (#266029)#266169

Merged
kibanamachine merged 1 commit intoelastic:9.4from
kibanamachine:backport/9.4/pr-266029
Apr 28, 2026
Merged

[9.4] Gracefully handle deprecated telemetry config (#266029)#266169
kibanamachine merged 1 commit intoelastic:9.4from
kibanamachine:backport/9.4/pr-266029

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.4:

Questions ?

Please refer to the Backport tool documentation

## Summary

Informed from [internal slack
thread](https://elastic.slack.com/archives/C0D8P2XK5/p1777023957119899)

`telemetry.enabled` is a deprecated config key. Its intended migration
path is to translate a value of `false` into `telemetry.optIn: false` +
`telemetry.allowChangingOptInStatus: false` and then remove the key, so
that the telemetry plugin itself continues to load while honoring the
user's intent to opt out. This allows dependent plugins — including
`security_solution`, `fleet`, and others that declare `telemetry` as a
`requiredPlugin` — to continue functioning normally.

## The bug

The deprecation handler was checking for the disabled case with strict
equality:

```ts
if (cfg.telemetry?.enabled === false) { ... }
```

This did not account for the string `"false"`, which is a valid YAML
value and one that `@kbn/config-schema`'s `schema.boolean()` type
explicitly coerces to the boolean `false`. The two systems run at
different moments in the startup pipeline:

1. **Deprecations run first**, against the raw, pre-schema config object
coming directly from `kibana.yml`. At this point `"false"` is still a
string, so `"false" === false` evaluates to `false` and the migration is
silently skipped.
2. **Schema validation runs second**, inside
`ConfigService.isEnabledAtPath`. Here `schema.boolean()` coerces the
string `"false"` to the boolean `false`, causing `isEnabledAtPath` to
return `false` and mark the plugin as disabled.

Because the plugin is disabled, every plugin that lists `telemetry` in
its `requiredPlugins` is also transitively disabled — including
`security_solution`, making it completely non-functional with no obvious
error pointing to the root cause.

## The fix

The deprecation handler is updated to match any value that
`schema.boolean()` would coerce to `false` — both the native boolean and
any case-insensitive string variant — before schema validation has a
chance to run, this ensures the migration fires regardless of how the
value is expressed in `kibana.yml` (`false`, `"false"`, `"False"`,
`"FALSE"`), removes `telemetry.enabled` from the config before
`isEnabledAtPath` inspects it, and applies the correct opt-out semantics
via `optIn` and `allowChangingOptInStatus`. The OpenTelemetry
sub-configs (`tracing.enabled`, `metrics.enabled`) are also set to
`false` for consistency.

## Tests

A new `deprecations: telemetry.enabled` suite is added to
`config.test.ts`. It drives the deprecation function directly through
`applyDeprecations` (the same code path core uses at startup), and
asserts:

- All four falsy variants (`false`, `"false"`, `"False"`, `"FALSE"`)
trigger the migration, unset `enabled`, and correctly populate `optIn`,
`allowChangingOptInStatus`, `tracing.enabled`, and `metrics.enabled`.
- Absent or truthy values (`undefined`, `true`, `"true"`, `"True"`,
`"TRUE"`) leave the config unchanged.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 6f3c889)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Apr 28, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) April 28, 2026 16:17
@kibanamachine
Copy link
Copy Markdown
Contributor Author

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @eokoneyo

@kibanamachine kibanamachine merged commit 4610967 into elastic:9.4 Apr 28, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants