[8.15] [Automatic Import] Error handling when uploading a file (#191310)#192464
Merged
bhapas merged 1 commit intoelastic:8.15from Sep 10, 2024
Merged
[8.15] [Automatic Import] Error handling when uploading a file (#191310)#192464bhapas merged 1 commit intoelastic:8.15from
bhapas merged 1 commit intoelastic:8.15from
Conversation
### Release note
Display better error messages for issues with logs sample file upload in
Automatic Import.
## Summary
Previously the user would be told about parse issues that occur after
the file is successfully uploaded. However in the following scenarios
the operation would silently fail without displaying a user-visible
error:
1. When the file fails to upload (e.g. when it is too big).
2. When the upload operation is aborted, e.g. programmatically.
Additionally in the following scenario the generic `CAN_NOT_PARSE`
message was displayed:
3. When the file is uploaded but the browser runs out of memory when
trying to parse it.
Additionally, in the following scenario the `EMPTY` message was
displayed:
4. When the file is too big for the V8 engine (e.g. Chrome) to create a
string so upload process returns an empty string.
Additionally:
5. When the user switches from the invalid file (with an error
displayed) to the valid file, the error from the invalid file was
displayed during the analysis of the new file.
After the changes in this PR, the following error types would be
displayed in these cases, respectively:
1. `CAN_NOT_READ_WITH_REASON`: _An error occurred when reading logs
sample: {reason}_
2. `CAN_NOT_READ_WITH_REASON`: _An error occurred when reading logs
sample: An ongoing operation was aborted, typically with a call to
abort()._ (reason is provided by the browser)
3. `TOO_LARGE_TO_PARSE`: _This logs sample file is too large to parse_
4. `TOO_LARGE_TO_PARSE`: _This logs sample file is too large to parse_
5. No error would be displayed during the analysis.
This covers part of elastic/security-team#9844
though the issues were discovered separately.
Note that the fix in item 3 does not work in Firefox as it throws an
`InternalError` rather than `RangeError`. A generic `CAN_NOT_PARSE`
message will continue to be displayed in that case. The fix in item 4 is
only relevant for Chrome.
On a slightly different note, we provide the following improvements to
the log sampling functionality introduced in
elastic#190407:
- Add documentation for the `parseLogsContents` and its special cases
- Refactor the `parseLogsContent` output fields into protocols that
clearly define their optionality
- Add tests for the functionality of sampling when the format cannot be
determined
- Fix so that the error message is displayed for the case where
`fileContent == null` in `onChangeLogsSample`
### Risk Matrix
| Risk | Probability | Severity | Mitigation/Notes |
|---------------------------|-------------|----------|-------------------------|
| Due to the complexity of browser engines, some of them might produce
unexpected events, or events in unexpected order and we will confuse the
user with an incorrect error message. | Low | Low | Testing. |
---------
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 16c2bfe)
5 tasks
Contributor
|
Pinging @elastic/security-scalability (Team:Security-Scalability) |
semd
approved these changes
Sep 10, 2024
haetamoudi
approved these changes
Sep 10, 2024
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
To update your PR or re-run it, just comment with: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.15:Questions ?
Please refer to the Backport tool documentation