Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from elastic:main #832

Merged
merged 10 commits into from
Dec 30, 2024
Merged

[pull] main from elastic:main #832

merged 10 commits into from
Dec 30, 2024

Conversation

pull[bot]
Copy link

@pull pull bot commented Dec 30, 2024

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

kibanamachine and others added 10 commits December 30, 2024 01:24
## Summary

Part of #204761

These packages are meant to be used by each render tree.
`react-kibana-context-theme` was already part of a shared bundle and
most of them were already part of Bazel, let's add all of them for
consistency and to reduce bundle size
Newer builds of ES ingest `event.ingested` and `tags` fields into APM
indices making the Dataset Quality tests fail which rely on ingested
field counts against set number of field limits. The PR addresses this
by explicitly ingesting the fields beforehand.

After the merge to main, the PR will be backported to `8.x` to unblock
es-promotion.
## Summary

Added `CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES` env var for `8.x`
branch to check if that speeds up the CodeQL run, refer to
[documentation](https://codeql.github.com/docs/codeql-overview/codeql-changelog/codeql-cli-2.15.5/)
for details.
…na-data-discovery` (#203152)

## Summary

This PR aims at relocating some of the Kibana modules (plugins and
packages) into a new folder structure, according to the _Sustainable
Kibana Architecture_ initiative.

> [!IMPORTANT]
> * We kindly ask you to:
> * Manually fix the errors in the error section below (if there are
any).
> * Search for the `packages[\/\\]` and `plugins[\/\\]` patterns in the
source code (Babel and Eslint config files), and update them
appropriately.
> * Manually review
`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to ensure that
any CI pipeline customizations continue to be correctly applied after
the changed path names
> * Review all of the updated files, specially the `.ts` and `.js` files
listed in the sections below, as some of them contain relative paths
that have been updated.
> * Think of potential impact of the move, including tooling and
configuration files that can be pointing to the relocated modules. E.g.:
>     * customised eslint rules
>     * docs pointing to source code

> [!NOTE]
> * This PR has been auto-generated.
> * Any manual contributions will be lost if the 'relocate' script is
re-run.
> * Try to obtain the missing reviews / approvals before applying manual
fixes, and/or keep your changes in a .patch / git stash.
> * Please use
[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)
Slack channel for feedback.

Are you trying to rebase this PR to solve merge conflicts? Please follow
the steps describe
[here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E).

#### 12 plugin(s) are going to be relocated:

| Id | Target folder |
| -- | ------------- |
| `@kbn/data-view-editor-plugin` |
`src/platform/plugins/shared/data_view_editor` |
| `@kbn/data-view-field-editor-plugin` |
`src/platform/plugins/shared/data_view_field_editor` |
| `@kbn/data-view-management-plugin` |
`src/platform/plugins/shared/data_view_management` |
| `@kbn/data-views-plugin` | `src/platform/plugins/shared/data_views` |
| `@kbn/discover-enhanced-plugin` |
`x-pack/platform/plugins/private/discover_enhanced` |
| `@kbn/discover-plugin` | `src/platform/plugins/shared/discover` |
| `@kbn/discover-shared-plugin` |
`src/platform/plugins/shared/discover_shared` |
| `@kbn/field-formats-plugin` |
`src/platform/plugins/shared/field_formats` |
| `@kbn/saved-objects-finder-plugin` |
`src/platform/plugins/shared/saved_objects_finder` |
| `@kbn/saved-search-plugin` |
`src/platform/plugins/shared/saved_search` |
| `@kbn/unified-doc-viewer-plugin` |
`src/platform/plugins/shared/unified_doc_viewer` |
| `@kbn/unified-histogram-plugin` |
`src/platform/plugins/shared/unified_histogram` |




#### 18 packages(s) are going to be relocated:

| Id | Target folder |
| -- | ------------- |
| `@kbn/content-management-utils` |
`src/platform/packages/shared/kbn-content-management-utils` |
| `@kbn/data-view-utils` |
`src/platform/packages/shared/kbn-data-view-utils` |
| `@kbn/datemath` | `src/platform/packages/shared/kbn-datemath` |
| `@kbn/deeplinks-analytics` |
`src/platform/packages/shared/deeplinks/analytics` |
| `@kbn/default-nav-analytics` |
`src/platform/packages/private/default-nav/analytics` |
| `@kbn/discover-utils` |
`src/platform/packages/shared/kbn-discover-utils` |
| `@kbn/es-query` | `src/platform/packages/shared/kbn-es-query` |
| `@kbn/field-types` | `src/platform/packages/shared/kbn-field-types` |
| `@kbn/field-utils` | `src/platform/packages/shared/kbn-field-utils` |
| `@kbn/react-field` | `src/platform/packages/shared/kbn-react-field` |
| `@kbn/resizable-layout` |
`src/platform/packages/shared/kbn-resizable-layout` |
| `@kbn/search-errors` |
`src/platform/packages/shared/kbn-search-errors` |
| `@kbn/search-response-warnings` |
`src/platform/packages/shared/kbn-search-response-warnings` |
| `@kbn/search-types` | `src/platform/packages/shared/kbn-search-types`
|
| `@kbn/unified-data-table` |
`src/platform/packages/shared/kbn-unified-data-table` |
| `@kbn/unified-doc-viewer` |
`src/platform/packages/shared/kbn-unified-doc-viewer` |
| `@kbn/unified-field-list` |
`src/platform/packages/shared/kbn-unified-field-list` |
| `@kbn/unsaved-changes-badge` |
`src/platform/packages/private/kbn-unsaved-changes-badge` |


<details >
<summary>Updated references</summary>

```
./.buildkite/scripts/steps/functional/scout_ui_tests.sh
./.eslintrc.js
./.i18nrc.json
./docs/developer/advanced/sharing-saved-objects.asciidoc
./docs/developer/architecture/core/saved-objects-service.asciidoc
./docs/developer/best-practices/navigation.asciidoc
./docs/developer/contributing/development-unit-tests.asciidoc
./docs/developer/plugin-list.asciidoc
./examples/unified_doc_viewer/README.md
./examples/unified_field_list_examples/public/plugin.ts
./legacy_rfcs/text/0015_bazel.md
./oas_docs/scripts/merge_ess_oas.js
./oas_docs/scripts/merge_serverless_oas.js
./package.json
./packages/kbn-repo-packages/package-map.json
./packages/kbn-synthetic-package-map/synthetic-packages.json
./packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js
./packages/kbn-ts-projects/config-paths.json
./packages/kbn-ui-shared-deps-src/BUILD.bazel
./packages/kbn-unified-field-list/src/services/field_examples_calculator/field_examples_calculator.ts
./packages/shared-ux/prompt/no_data_views/types/index.d.ts
./src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt
./src/dev/storybook/aliases.ts
./src/platform/packages/private/default-nav/analytics/jest.config.js
./src/platform/packages/private/kbn-unsaved-changes-badge/jest.config.js
./src/platform/packages/shared/deeplinks/analytics/jest.config.js
./src/platform/packages/shared/kbn-content-management-utils/jest.config.js
./src/platform/packages/shared/kbn-data-view-utils/jest.config.js
./src/platform/packages/shared/kbn-datemath/jest.config.js
./src/platform/packages/shared/kbn-discover-utils/jest.config.js
./src/platform/packages/shared/kbn-es-query/jest.config.js
./src/platform/packages/shared/kbn-field-types/jest.config.js
./src/platform/packages/shared/kbn-field-utils/jest.config.js
./src/platform/packages/shared/kbn-react-field/jest.config.js
./src/platform/packages/shared/kbn-resizable-layout/jest.config.js
./src/platform/packages/shared/kbn-search-errors/jest.config.js
./src/platform/packages/shared/kbn-search-response-warnings/jest.config.js
./src/platform/packages/shared/kbn-search-types/jest.config.js
./src/platform/packages/shared/kbn-unified-data-table/jest.config.js
./src/platform/packages/shared/kbn-unified-doc-viewer/jest.config.js
./src/platform/packages/shared/kbn-unified-field-list/jest.config.js
./src/platform/plugins/shared/data_view_editor/jest.config.js
./src/platform/plugins/shared/data_view_field_editor/jest.config.js
./src/platform/plugins/shared/data_view_management/jest.config.js
./src/platform/plugins/shared/data_views/jest.config.js
./src/platform/plugins/shared/discover/README.md
./src/platform/plugins/shared/discover/jest.config.js
./src/platform/plugins/shared/discover/public/context_awareness/README.md
./src/platform/plugins/shared/discover_shared/README.md
./src/platform/plugins/shared/discover_shared/jest.config.js
./src/platform/plugins/shared/field_formats/jest.config.js
./src/platform/plugins/shared/saved_objects_finder/jest.config.js
./src/platform/plugins/shared/saved_search/jest.config.js
./src/platform/plugins/shared/unified_doc_viewer/jest.config.js
./src/platform/plugins/shared/unified_histogram/jest.config.js
./tsconfig.base.json
./tsconfig.refs.json
./x-pack/.i18nrc.json
./x-pack/platform/plugins/private/discover_enhanced/jest.config.js
./x-pack/platform/plugins/private/discover_enhanced/ui_tests/README.md
./x-pack/solutions/security/plugins/timelines/common/search_strategy/index_fields/index.ts
./yarn.lock
.github/CODEOWNERS
```

</details><details >
<summary>Updated relative paths</summary>

```
src/platform/packages/private/default-nav/analytics/jest.config.js:12
src/platform/packages/private/default-nav/analytics/tsconfig.json:2
src/platform/packages/private/kbn-unsaved-changes-badge/jest.config.js:12
src/platform/packages/private/kbn-unsaved-changes-badge/tsconfig.json:2
src/platform/packages/shared/deeplinks/analytics/jest.config.js:12
src/platform/packages/shared/deeplinks/analytics/tsconfig.json:2
src/platform/packages/shared/kbn-content-management-utils/jest.config.js:12
src/platform/packages/shared/kbn-content-management-utils/tsconfig.json:2
src/platform/packages/shared/kbn-data-view-utils/jest.config.js:12
src/platform/packages/shared/kbn-data-view-utils/tsconfig.json:2
src/platform/packages/shared/kbn-datemath/jest.config.js:22
src/platform/packages/shared/kbn-datemath/tsconfig.json:2
src/platform/packages/shared/kbn-discover-utils/jest.config.js:12
src/platform/packages/shared/kbn-discover-utils/tsconfig.json:2
src/platform/packages/shared/kbn-es-query/jest.config.js:12
src/platform/packages/shared/kbn-es-query/tsconfig.json:2
src/platform/packages/shared/kbn-field-types/jest.config.js:12
src/platform/packages/shared/kbn-field-types/tsconfig.json:2
src/platform/packages/shared/kbn-field-utils/jest.config.js:12
src/platform/packages/shared/kbn-field-utils/tsconfig.json:2
src/platform/packages/shared/kbn-react-field/jest.config.js:12
src/platform/packages/shared/kbn-react-field/tsconfig.json:2
src/platform/packages/shared/kbn-resizable-layout/jest.config.js:12
src/platform/packages/shared/kbn-resizable-layout/tsconfig.json:2
src/platform/packages/shared/kbn-search-errors/jest.config.js:12
src/platform/packages/shared/kbn-search-errors/tsconfig.json:2
src/platform/packages/shared/kbn-search-response-warnings/jest.config.js:12
src/platform/packages/shared/kbn-search-response-warnings/tsconfig.json:2
src/platform/packages/shared/kbn-search-types/jest.config.js:12
src/platform/packages/shared/kbn-search-types/tsconfig.json:2
src/platform/packages/shared/kbn-unified-data-table/jest.config.js:12
src/platform/packages/shared/kbn-unified-data-table/tsconfig.json:2
src/platform/packages/shared/kbn-unified-doc-viewer/jest.config.js:12
src/platform/packages/shared/kbn-unified-doc-viewer/tsconfig.json:2
src/platform/packages/shared/kbn-unified-field-list/jest.config.js:12
src/platform/packages/shared/kbn-unified-field-list/tsconfig.json:2
src/platform/plugins/shared/data_view_editor/jest.config.js:12
src/platform/plugins/shared/data_view_editor/tsconfig.json:2
src/platform/plugins/shared/data_view_field_editor/jest.config.js:12
src/platform/plugins/shared/data_view_field_editor/tsconfig.json:2
src/platform/plugins/shared/data_view_field_editor/tsconfig.json:7
src/platform/plugins/shared/data_view_management/jest.config.js:12
src/platform/plugins/shared/data_view_management/tsconfig.json:2
src/platform/plugins/shared/data_views/jest.config.js:12
src/platform/plugins/shared/data_views/tsconfig.json:2
src/platform/plugins/shared/discover/jest.config.js:12
src/platform/plugins/shared/discover/public/application/context/context_app.scss:1
src/platform/plugins/shared/discover/public/application/main/components/layout/discover_layout.scss:1
src/platform/plugins/shared/discover/public/context_awareness/README.md:118
src/platform/plugins/shared/discover/public/context_awareness/README.md:119
src/platform/plugins/shared/discover/tsconfig.json:10
src/platform/plugins/shared/discover/tsconfig.json:2
src/platform/plugins/shared/discover_shared/jest.config.js:12
src/platform/plugins/shared/discover_shared/tsconfig.json:10
src/platform/plugins/shared/discover_shared/tsconfig.json:2
src/platform/plugins/shared/field_formats/jest.config.js:12
src/platform/plugins/shared/field_formats/tsconfig.json:2
src/platform/plugins/shared/saved_objects_finder/jest.config.js:12
src/platform/plugins/shared/saved_objects_finder/tsconfig.json:2
src/platform/plugins/shared/saved_search/jest.config.js:12
src/platform/plugins/shared/saved_search/tsconfig.json:2
src/platform/plugins/shared/saved_search/tsconfig.json:6
src/platform/plugins/shared/unified_doc_viewer/jest.config.js:12
src/platform/plugins/shared/unified_doc_viewer/tsconfig.json:2
src/platform/plugins/shared/unified_doc_viewer/tsconfig.json:6
src/platform/plugins/shared/unified_histogram/jest.config.js:12
src/platform/plugins/shared/unified_histogram/tsconfig.json:2
src/platform/plugins/shared/unified_histogram/tsconfig.json:6
x-pack/platform/plugins/private/discover_enhanced/jest.config.js:10
x-pack/platform/plugins/private/discover_enhanced/tsconfig.json:2
```

</details>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…205138)

**Resolves: #202016

## Summary

This PR resolves an issue where the diff view incorrectly marked certain
characters as changed (using bold font) in some cases.

## Root Cause
The issue arises from a bug in the `diff` library (v5). The library is
used to compute two-way diffs between strings (old field value and new
field value), producing an array of change objects that is then used for
rendering.

Conditions for the bug:
- `diff` v5 library is in use (fixed in v6 and above) and
`DiffMethod.WORDS` is passed as a parameter to it.
- The old field value contains a line with an addition separated by a
space (see example below).
- The next line contains some changes (additions, deletions, or
updates).


For example, for these input strings:
```
foo bar
spring
```
```
foo
sprint
```

| You would expect to see this diff | But you actually see this |
|----------|----------|
| <img width="119" alt="expected"
src="https://github.com/user-attachments/assets/c41b3dec-e578-4a12-8eb8-91fbb60d7247"
/> | <img width="118" alt="actual"
src="https://github.com/user-attachments/assets/f2a33fee-5de2-4291-876a-e7575ea07079"
/> |

**A more real-life example**
<img width="1661" alt="more_real_life"
src="https://github.com/user-attachments/assets/91ebfe93-81ad-45c8-8f9b-e173c2cf940b"
/>


## Solution
Switching to `DiffMethod.WORDS_WITH_SPACE` avoids this issue. 
Screenshot showing the difference between `DiffMethod.WORDS` and
`DiffMethod.WORDS_WITH_SPACE`:
<img width="675" alt="words_vs_words_with_space"
src="https://github.com/user-attachments/assets/3c91e1d2-63fc-4fcd-a762-a905878bfc3a"
/>

## Other changes
- Removed `DiffMethod.TRIMMED_LINES` since it's now
[deprecated](kpdecker/jsdiff#486) in the `diff`
library and we are not using it anyways.
- Stopped using the "zip" option since I believe it produces a less
readable diff, especially for cases when there's a different number of
lines in the original value vs updated value.

<details>
<summary><strong>Screenshots: with and without "zip" (click to
expand)</strong></summary>
<strong>With the "zip" option (how it was before)</strong>
<img width="1918" alt="zip"
src="https://github.com/user-attachments/assets/272ed849-47d6-4fef-8acc-ab1b22c9f42e"
/>

<strong>No "zip" (this branch)</strong>
<img width="1919" alt="no_zip"
src="https://github.com/user-attachments/assets/417303bf-9570-4ee1-98c5-8a78f59c7956"
/>
</details>

## Testing

I thoroughly tested with `DiffMethod.WORDS_WITH_SPACE` across various
inputs and scenarios, including:
- Single-line and multi-line strings.
- Numbers, arrays, and objects.
- Additions, deletions, and updates at different positions (start,
middle, and end) within and across lines.

I also validated diffs against real prebuilt rules by installing an
older Fleet package version and observed no issues.

You can test by trying different input strings and settings in
Storybook.
**Run Storybook**: `yarn storybook security_solution`.


https://github.com/user-attachments/assets/0440b73c-a4d7-40cf-9cee-e632146d292e

You can notice that `ComparisonSide` stories are broken, but that's
unrelated to these changes and needs to be handled separately.

## Compatibility with future upgrades

There's an open [PR](#202622) that
will upgrade the `diff` library from v5 to v7. I verified the behavior
of `DiffMethod.WORDS_WITH_SPACE` on v7 and found no differences compared
to v5, so it should be safe to upgrade to v7 without any changes on our
end.

Work started on 23-Dec-2024.
## Summary

Part of #204761 . This package
is used by every app and I thought it is worth adding it to the shared
bundle. Especially since it is already part of Bazel.
fixes [#205240](#205240)

## Summary

Fixes the issue where `error.culprit` is always missing.

<img width="800" alt="image"
src="https://github.com/user-attachments/assets/9dad6797-dd40-4206-b508-daf8d69d653d"
/>

<img width="800" alt="image"
src="https://github.com/user-attachments/assets/6a0ac25a-bc4b-4a26-b126-86eecbe7e769"
/>



### How to test 

- Run `simple_trace` synthtrace scenario
- Run the request below
<details>
<summary>POST logs-apm.error-default/_doc</summary>

```
POST logs-apm.error-default/_doc
{

    "container": {
      "id": "80cc20ecab1b57865d7aca0f66ab75a0c6ec2c51f7c53da04a8540215369c359"
    },
    "kubernetes": {
      "node": {
        "name": "ip-192-168-55-136.ec2.internal"
      },
      "pod": {
        "uid": "9bbfe3dc-dace-4638-b8f5-aa6ccf435cbe",
        "name": "otel-demo-green-3-cartservice-5d5ccc86dd-gcxtr"
      },
      "namespace": "otel-demo-green-3"
    },
    "parent": {
      "id": "f39639f56a540e0e"
    },
    "agent": {
      "name": "opentelemetry/dotnet",
      "version": "1.6.0"
    },
    "source": {
      "port": 35136,
      "ip": "::ffff:192.168.50.132"
    },
    "error": {
      "exception": [
        {
          "handled": true,
          "message": "Exception (plain, .NET) without culprit",
          "type": "Grpc.Core.RpcException"
        }
      ],
      "culprit": "culprit msg", // remove to test the N/A scenario
      "id": "60674e9b23c8b06d83889e63ffe82c1c", //change the id on every run
      "stack_trace": "Grpc.Core.RpcException: Status(StatusCode=\"FailedPrecondition\", Detail=\"Can't access cart storage. System.ApplicationException: Wasn't able to connect to redis\n   at cartservice.cartstore.RedisCartStore.EnsureRedisConnected() in /usr/src/app/src/cartstore/RedisCartStore.cs:line 79\n   at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 157\")\n   at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 166\n   at cartservice.services.CartService.EmptyCart(EmptyCartRequest request, ServerCallContext context) in /usr/src/app/src/services/CartService.cs:line 65",
      "grouping_key": "6082c58afd7fa6838ebc27eef6e04829"
    },
    "message": "Exception (plain, .NET)",
    "url": {
      "path": "/oteldemo.CartService/EmptyCart",
      "original": "http://otel-demo-green-3-cartservice:8080/oteldemo.CartService/EmptyCart",
      "scheme": "http",
      "port": 8080,
      "domain": "otel-demo-green-3-cartservice",
      "full": "http://otel-demo-green-3-cartservice:8080/oteldemo.CartService/EmptyCart"
    },
    "labels": {
      "k8s_pod_ip": "192.168.62.174",
      "k8s_pod_start_time": "2024-12-17T02:55:54Z",
      "service_namespace": "opentelemetry-demo",
      "k8s_deployment_name": "otel-demo-green-3-cartservice"
    },
    "observer": {
      "hostname": "450fbf7ab701",
      "type": "apm-server",
      "version": "8.13.2"
    },
    "trace": {
      "id": "699f6d1039fc873191a1c983790db3a2"
    },
    "@timestamp": "2024-12-30T10:30:00.000Z",
    "data_stream": {
      "namespace": "default",
      "type": "logs",
      "dataset": "apm.error"
    },
    "service": {
      "node": {
        "name": "80cc20ecab1b57865d7aca0f66ab75a0c6ec2c51f7c53da04a8540215369c359"
      },
      "framework": {
        "name": "Microsoft.AspNetCore"
      },
       "name": "synth-node-0",
      "language": {
        "name": "dotnet"
      }
    },
    "host": {
      "hostname": "ip-192-168-55-136.ec2.internal",
      "name": "ip-192-168-55-136.ec2.internal"
    },
    "client": {
      "port": 35136,
      "ip": "::ffff:192.168.50.132"
    },
    "http": {
      "request": {
        "method": "POST"
      },
      "response": {
        "status_code": 200
      },
      "version": "2"
    },
    "event": {
      "agent_id_status": "missing",
      "ingested": "2024-12-18T18:04:22Z"
    },
    "transaction": {
      "id": "f39639f56a540e0e",
      "type": "request",
      "sampled": true
    },
    "user_agent": {
      "original": "grpc-go/1.59.0",
      "name": "Other",
      "device": {
        "name": "Other"
      }
    },
    "span": {
      "id": "f39639f56a540e0e"
    },
    "timestamp": {
      "us": 1704892605838000
    }
  }
```
</details>
@pull pull bot added the ⤵️ pull label Dec 30, 2024
@pull pull bot merged commit 12608c3 into miqdigital:main Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants