Skip to content

Conversation

@nikhilsaikethe
Copy link
Contributor

@nikhilsaikethe nikhilsaikethe commented Oct 29, 2024

This PR fixes
1.#4935
2.This also tries to add wrap the stream name into double quotes so whenever any field also contain the stream name it ignores that

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for search results, improving user feedback based on various error states.
    • Improved accuracy in SQL query modifications related to stream names, preventing unintended replacements.
    • More precise filtering of fields during removal, enhancing the field management process.
    • Adjusted histogram interval conditions for better data generation, resulting in finer granularity.
    • More descriptive error messages for improved user notifications during search operations.
  • Bug Fixes

    • Refined query cancellation process to notify users effectively if a search query is interrupted.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes in this pull request enhance the error handling and field management logic within the logs search functionality in web/src/plugins/logs/Index.vue and improve query processing in web/src/composables/useLogs.ts. Key modifications include an updated removeFieldByName function for more accurate field removal, a refined setInterestingFieldInSQLQuery method that employs regular expressions for SQL query adjustments, and improved control flow for displaying error messages based on the state of searchObj. Additionally, the histogram interval condition has been adjusted, and error messages have become more descriptive in the useLogs composable.

Changes

File Change Summary
web/src/plugins/logs/Index.vue - Enhanced error message handling based on searchObj state.
- Updated removeFieldByName function for improved field removal accuracy.
- Modified setInterestingFieldInSQLQuery to use regex for precise SQL query modifications.
- Refined control flow for better UI response to search state changes.
web/src/composables/useLogs.ts - Adjusted histogram interval condition from <= 60000 to <= 9999 milliseconds.
- Enhanced error messages in getHistogramQueryData function.
- Improved error handling for canceled search operations.

Possibly related PRs

Suggested labels

🧹 Updates

Suggested reviewers

  • omkarK06

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 10ef74e and 02f1bd4.

📒 Files selected for processing (2)
  • web/src/composables/useLogs.ts (1 hunks)
  • web/src/plugins/logs/Index.vue (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/composables/useLogs.ts
  • web/src/plugins/logs/Index.vue

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Oct 29, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 03897e7 and c5ce6a9.

📒 Files selected for processing (1)
  • web/src/plugins/logs/Index.vue (2 hunks)
🧰 Additional context used
📓 Learnings (1)
web/src/plugins/logs/Index.vue (1)
Learnt from: bjp232004
PR: openobserve/openobserve#4841
File: web/src/plugins/logs/SearchResult.vue:445-455
Timestamp: 2024-10-21T11:16:45.923Z
Learning: In the OpenObserve project, changes to the `addSearchTerm` function's signature in `web/src/plugins/logs/SearchResult.vue` do not require updating its usage in other components such as `BasicValuesFilter.vue`, `FieldList.vue`, or `SearchBar.vue`.

if (
(item.expr.type === "column_ref" &&
item.expr?.column?.expr?.value === fieldName) ||
item.expr?.column?.expr?.value === fieldName || item.expr.column === fieldName) ||
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure correct logical operator precedence in removeFieldByName.

The condition combines && and || operators without explicit parentheses, which may lead to unintended logic due to operator precedence rules. It's recommended to use parentheses to clearly define the intended logic.

Apply this diff to fix the condition:

- if (
-   (item.expr.type === "column_ref" &&
-     item.expr?.column?.expr?.value === fieldName || item.expr.column === fieldName) ||
-   (item.expr.type === "aggr_func" &&
-     item.expr?.args?.expr?.column?.value === fieldName)
- ) {
+ if (
+   (item.expr.type === "column_ref" &&
+     (item.expr?.column?.expr?.value === fieldName || item.expr.column === fieldName)
+   ) ||
+   (item.expr.type === "aggr_func" &&
+     item.expr?.args?.expr?.column?.value === fieldName)
+ ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
item.expr?.column?.expr?.value === fieldName || item.expr.column === fieldName) ||
(item.expr?.column?.expr?.value === fieldName || item.expr.column === fieldName)) ||

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct and I have updated accordingly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikhilsaikethe, glad to hear that you've updated the code accordingly!

((
( ^^)
(
(")(")


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

Comment on lines 947 to 949
new RegExp(`\\b${searchObj.data.stream.selectedStream[0]}\\b`, 'g'), // Wrap only standalone 'default'
`"${searchObj.data.stream.selectedStream[0]}"`
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Escape stream name in regular expression to handle special characters.

When constructing the regular expression with searchObj.data.stream.selectedStream[0], if the stream name contains special regex characters (e.g., ., *, +), it could lead to incorrect matching or runtime errors. To ensure the regex functions correctly, escape the stream name.

Apply this diff to fix the issue:

+ const streamName = searchObj.data.stream.selectedStream[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  const newQuery = parser
    .sqlify(parsedSQL)
    .replace(/`/g, "")
    .replace(
-     new RegExp(`\\b${searchObj.data.stream.selectedStream[0]}\\b`, 'g'), // Wrap only standalone 'default'
+     new RegExp(`\\b${streamName}\\b`, 'g'), // Wrap only standalone stream name
      `"${searchObj.data.stream.selectedStream[0]}"`
    );

Committable suggestion was skipped due to low confidence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes used this only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikhilsaikethe, great to hear that you've applied the fix!

(_/)
(^.^)
(")_(")


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

@nikhilsaikethe nikhilsaikethe force-pushed the issue_4935 branch 4 times, most recently from f058a65 to 10ef74e Compare October 30, 2024 12:24
@bjp232004 bjp232004 merged commit 61ce5a0 into main Oct 31, 2024
26 checks passed
@bjp232004 bjp232004 deleted the issue_4935 branch October 31, 2024 04:18
hengfeiyang pushed a commit that referenced this pull request Nov 1, 2024
This PR fixes 
1.#4935 
2.This also tries to add wrap the stream name into double quotes so
whenever any field also contain the stream name it ignores that

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced error handling for search results, improving user feedback
based on various error states.
- Improved accuracy in SQL query modifications related to stream names,
preventing unintended replacements.
- More precise filtering of fields during removal, enhancing the field
management process.
- Adjusted histogram interval conditions for better data generation,
resulting in finer granularity.
- More descriptive error messages for improved user notifications during
search operations.

- **Bug Fixes**
- Refined query cancellation process to notify users effectively if a
search query is interrupted.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants