Skip to content

bugfixes for target separation #1365

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

parmesant
Copy link
Contributor

@parmesant parmesant commented Jul 3, 2025

Fixes include-

  • Removal of duplication check
  • Proper loading of targets on server init
  • Masking of sensitive information (slack URL, alert manager auth credentials)
  • Error on modifying name
  • Renaming repeat to notificationConfig and setting least count of interval to 1 minute

Description


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Summary by CodeRabbit

  • New Features

    • Sensitive information in target data is now masked in all relevant API responses.
    • Added a new resource that is loaded during application initialization.
  • Bug Fixes

    • Improved error handling for invalid modifications to target configurations, including clearer error messages when attempting to change a target's name.
  • Refactor

    • Unified and simplified notification configuration fields and interval handling for targets.
    • Updated naming conventions for notification settings to improve clarity.

Copy link
Contributor

coderabbitai bot commented Jul 3, 2025

Walkthrough

This update refactors alert target notification configuration, renaming and simplifying fields, switching interval units to integer minutes, and adding masking for sensitive target data in HTTP responses. It removes duplicate target validation, updates error handling, and introduces a new resource load step for targets during initialization.

Changes

File(s) Change Summary
src/alerts/mod.rs Refactored validation to use new notification config fields and interval logic; replaced DuplicateTargetConfig error with InvalidTargetModification(String); updated error handling accordingly.
src/alerts/target.rs Renamed and retyped notification config fields; replaced duration types with integer minutes; added mask() for sensitive data; removed duplicate target check; updated related structs and verifiers.
src/handlers/http/modal/mod.rs Added loading of TARGETS resource during initialization, updating async logic to handle five concurrent loads.
src/handlers/http/targets.rs Applied .mask() to all Target responses to hide sensitive fields; added name immutability check in update handler.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HTTP_Handler
    participant TargetStore

    Client->>HTTP_Handler: POST/GET/UPDATE/DELETE /targets
    HTTP_Handler->>TargetStore: Fetch/Update Target(s)
    TargetStore-->>HTTP_Handler: Target object(s)
    HTTP_Handler->>HTTP_Handler: Mask sensitive fields via .mask()
    HTTP_Handler-->>Client: Return masked Target(s)
Loading
sequenceDiagram
    participant App
    participant Alerts
    participant Targets

    App->>Alerts: load_on_init()
    Alerts->>Alerts: Load ALERTS, ALERT_HISTORY, ALERT_RULES, ALERT_GROUPS
    Alerts->>Targets: Load TARGETS
    Targets-->>Alerts: TARGETS loaded or error
    Alerts-->>App: Initialization complete (logs errors if any)
Loading

Suggested reviewers

  • nikhilsinhaparseable

Poem

In fields of code where targets dwell,
A rabbit hops, with secrets to quell.
Now masked and safe, the data flows,
With minutes clear, and error shows.
Five loads at dawn, a gentle start—
Refactored well, with rabbit heart! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)
Updating crates.io index
Updating git repository `https://github.com/parseablehq/opentelemetry-rust`

error: failed to get opentelemetry-proto as a dependency of package parseable v2.3.5 ()

Caused by:
failed to load source for dependency opentelemetry-proto

Caused by:
Unable to update https://github.com/parseablehq/opentelemetry-rust?branch=fix-metrics-u64-serialization#7e84c98d

Caused by:
failed to create directory /usr/local/git/db/opentelemetry-rust-e71049053dacb49f

Caused by:
Permission denied (os error 13)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8bbdd22 and f7b4afd.

📒 Files selected for processing (4)
  • src/alerts/mod.rs (4 hunks)
  • src/alerts/target.rs (8 hunks)
  • src/handlers/http/modal/mod.rs (3 hunks)
  • src/handlers/http/targets.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: de-sh
PR: parseablehq/parseable#0
File: :0-0
Timestamp: 2025-03-20T15:50:45.435Z
Learning: Pay close attention to code comments for typos and semantic clarity during reviews for the Parseable project.
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: coverage
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
🔇 Additional comments (20)
src/handlers/http/modal/mod.rs (3)

37-37: LGTM: Proper integration of TARGETS resource.

The import addition aligns with the broader target management integration.


176-189: LGTM: Consistent resource loading pattern.

The change from join4 to join5 properly integrates targets loading during initialization, following the same pattern as other resources.


208-211: LGTM: Proper error handling for targets.

Error handling for targets follows the same pattern as other resources.

src/handlers/http/targets.rs (4)

5-5: LGTM: Necessary import for collection functionality.

The Itertools import supports the .collect_vec() usage in the list handler.


22-22: Excellent security enhancement with consistent masking.

The .mask() method is consistently applied across all endpoints that return target data, ensuring sensitive information like Slack URLs and AlertManager credentials are properly obscured in API responses.

Also applies to: 44-44, 72-72, 84-84


28-33: LGTM: Proper masking in list endpoint.

The list endpoint correctly applies masking to each target before returning the collection.


56-63: Good validation: Prevents unauthorized target name modification.

This validation properly enforces immutability of target names during updates, which is a good security practice to prevent potential confusion or unauthorized changes.

src/alerts/mod.rs (3)

31-31: LGTM: Necessary import for time calculations.

The Duration import is needed for the updated notification interval calculations.


614-619: LGTM: Proper field renaming and time unit conversion.

The change from timeout to notification_config is consistent with the broader refactoring. The time calculation correctly converts minutes to seconds by multiplying the interval by 60.


859-860: LGTM: Consistent error handling update.

The error variant change from DuplicateTargetConfig to InvalidTargetModification aligns with the new validation logic in the HTTP handlers and maintains the same BAD_REQUEST status code.

Also applies to: 881-881

src/alerts/target.rs (10)

33-33: LGTM: Necessary imports for JSON masking functionality.

The additional imports support the new masking functionality.


143-143: LGTM: Consistent field renaming.

The rename from timeout to notification_config improves semantic clarity and aligns with the broader refactoring.


149-204: Excellent implementation of sensitive data masking.

The mask() method provides comprehensive protection for sensitive data:

  • Slack endpoints are truncated to show only the first 20 characters
  • AlertManager passwords are completely replaced with asterisks
  • Other webhook data remains visible as it's typically not sensitive

The JSON structure is well-organized and maintains API compatibility.


208-208: LGTM: Consistent field reference update.

The change from timeout to notification_config maintains consistency with the field renaming.


256-256: LGTM: Proper time unit conversion.

The multiplication by 60 correctly converts the interval from minutes (u64) to seconds for the Duration::from_secs call.


327-330: LGTM: Consistent struct and field renaming with type simplification.

The rename from RepeatVerifier to NotificationConfigVerifier and the type change from Option<String> to Option<u64> for interval simplifies configuration by removing the need to parse human-readable duration strings.


339-339: LGTM: Consistent field renaming in verifier struct.

The field rename maintains consistency with the overall refactoring.


355-365: LGTM: Simplified conversion logic.

The updated conversion logic properly handles the new u64 interval type, removing the complexity of parsing duration strings while maintaining the same functionality.


370-370: LGTM: Consistent field usage.

The field name update maintains consistency with the refactoring.


565-565: LGTM: Simplified interval handling with appropriate default.

The type change from Duration to u64 (representing minutes) simplifies configuration. The default value of 1 minute aligns with the PR requirement for a minimum interval of one minute.

Also applies to: 575-575

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

"id":self.id
})
}
TargetType::Other(other_web_hook) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@parmesant are we not masking the webhook endpoint? why is there a different behaviour?
we should mask all endpoints irrespective of the target type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants