Skip to content

Conversation

@nikhilsaikethe
Copy link
Contributor

  1. converting severity to integer before checking status
  2. match for exact word instead of shortforms to match the color

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Failed to generate code suggestions for PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

This PR improves status color detection for log entries by:

  • Converting numeric strings (e.g., "0", "3") to numbers before parsing, enabling correct syslog severity mapping
  • Changing from prefix-based string matching to exact word matching, preventing false positives (e.g., words starting with 'a' no longer incorrectly match 'alert')

Key Changes:

  • Added numeric string conversion in extractStatusFromLog() before calling parseStatusValue()
  • Replaced all startsWith() checks in mapStringStatus() with exact equality comparisons

Potential Issue:

  • Empty strings and whitespace-only strings will be converted to 0 (since Number("") === 0), incorrectly mapping them to "emergency" level instead of the expected "info" fallback

Confidence Score: 3/5

  • PR addresses real issues but introduces an edge case bug with empty strings that should be fixed before merging
  • The main changes (exact matching and numeric string conversion) are sensible improvements. However, the empty string edge case could cause unexpected behavior where logs with empty status fields show as "emergency" level with red color instead of the default "info" level.
  • web/src/utils/logs/statusParser.ts - line 92 needs the empty string edge case handled

Important Files Changed

File Analysis

Filename Score Overview
web/src/utils/logs/statusParser.ts 3/5 Converts numeric strings to numbers for correct severity mapping and changes string matching from prefix-based to exact word matching. Contains potential edge case with empty strings being converted to 0 (emergency level).

Sequence Diagram

sequenceDiagram
    participant Log as Log Entry
    participant Extract as extractStatusFromLog()
    participant Parse as parseStatusValue()
    participant MapNum as mapNumericStatus()
    participant MapStr as mapStringStatus()

    Log->>Extract: { severity: "3" }
    Extract->>Extract: Convert "3" to 3
    Extract->>Parse: value = 3 (number)
    Parse->>MapNum: value = 3
    MapNum-->>Parse: { level: 'error', priority: 3 }
    Parse-->>Extract: StatusInfo
    Extract-->>Log: { level: 'error', color: '#dc2626' }

    Note over Extract: Empty string edge case:
    Log->>Extract: { severity: "" }
    Extract->>Extract: Number("") = 0
    Extract->>Parse: value = 0 (number)
    Parse->>MapNum: value = 0
    MapNum-->>Parse: { level: 'emergency', priority: 0 }
    Note right of MapNum: Bug: should be 'info'
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@nikhilsaikethe nikhilsaikethe force-pushed the fix/logs-status-parser-issue branch from 01ecf5b to 1161d1d Compare December 3, 2025 04:49
@nikhilsaikethe nikhilsaikethe merged commit 26625e7 into main Dec 3, 2025
37 of 38 checks passed
@nikhilsaikethe nikhilsaikethe deleted the fix/logs-status-parser-issue branch December 3, 2025 05:34
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.

2 participants