You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[7.17][Lens] Error onRecords aggregation field when switching i18n.locale (elastic#224970)
## Summary
This PR fixes an issue where switching to any `locale` other than `'en'`
would cause the error `未找到字段 Records` or `Field Records not found`.
This was first fix in elastic#123894 or `v8.1.0` but never backported to `7.x`.
> Note: This would only occur if someone saved a dashboard/vis in a
different `locale` then they are currently using or for hardcoded sample
data dashboards.
Fixeselastic#224593
## The solution
The fix applied in elastic#123894 is very invasive and corrects all usages of
the translated `name` across the source code and saved objects.
I would rather avoid that in `7.17` with a simpler hot fix. Mostly
because the full fix will already be applied in the migrations when
upgrading to `8.1.0`.
This fix for `7.17` just provides the `documentField` when the `field`
lookup fails and the `column.operationType` is `'count'`.
## The issue
The main issue is call to `indexPattern.getFieldByName(sourceField)`
below...
https://github.com/elastic/kibana/blob/e670d16d1e3c728ec9e2c21a9363d477ae663e2a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.tsx#L25
All fields of an index pattern are sourced from the mapping of the
elasticsearch index, with the exception of the `Records` field, which is
injected into the field list dynamically. But the definition of this
`documentField` below also translates the `name` property. Thus the
`sourceField` lookup value is sometimes `'Records'` and sometimes `'记录'`
(i.e. `'Records'` in Chinese).
https://github.com/elastic/kibana/blob/e670d16d1e3c728ec9e2c21a9363d477ae663e2a/x-pack/plugins/lens/public/indexpattern_datasource/document_field.ts#L16-L21
This translation should only apply to the `displayName` property of the
`documentField`, originally there was only a `name` property.
The issue now comes from the saved object of the sample data dashboard
where `sourceField` remains as `'Records'`, causing the field not found
error.
In current `main` we treat this document name as a constant
`__records__`, since elastic#123894.
https://github.com/elastic/kibana/blob/f0b862f1136c31a0761b6f19ba06411fb52b4959/x-pack/platform/plugins/shared/lens/public/datasources/form_based/document_field.ts#L12-L27
## Release Notes
Fixes a field lookup issue for count aggregations in Lens when using a
locale other than 'en'.
0 commit comments