Skip to content

Conversation

@nikhilsaikethe
Copy link
Contributor

This pr fixes the issue in #9566

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

Failed to generate code suggestions for PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 11, 2025

Greptile Overview

Greptile Summary

This PR fixes issue #9566 where 3-digit numbers below 600 were incorrectly colored as HTTP status codes in the logs page. The fix replaces the overly broad regex pattern /^[1-5]\d{2}$/ with a strict pattern that matches only valid HTTP status codes.

Key Changes:

  • Updated regex in useLogsHighlighter.ts:363 to match only valid HTTP status codes: 100-103 (Informational), 200-208 & 226 (Success), 300-308 (Redirection), 400-431 & 451 (Client Error), 500-511 (Server Error)
  • Applied the same pattern consistently in useTextHighlighter.ts at lines 415 and 548
  • Added comprehensive test coverage for both valid HTTP status codes and invalid 3-digit numbers like "147" (address numbers)

Impact:

  • Numbers like "147 Birch Way" will no longer be incorrectly highlighted in red as HTTP error codes
  • Only actual HTTP status codes will receive semantic colorization
  • Test coverage ensures this cosmetic bug won't regress

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a targeted cosmetic fix with excellent test coverage.
  • The change is well-scoped to fixing a cosmetic issue where arbitrary 3-digit numbers were incorrectly styled as HTTP status codes. The regex pattern correctly identifies valid HTTP status codes, comprehensive tests verify both positive and negative cases, and the fix is applied consistently across all text processing functions. No functional logic or data handling is affected.
  • No files require special attention - all changes are straightforward regex pattern updates with corresponding test coverage.

Important Files Changed

File Analysis

Filename Score Overview
web/src/composables/useLogsHighlighter.ts 5/5 Updated HTTP status code regex pattern from broad /^[1-5]\d{2}$/ to strict pattern matching only valid HTTP status codes (100-103, 200-208, 226, 300-308, 400-431, 451, 500-511). This fixes the issue where numbers like 147 were incorrectly highlighted as status codes.
web/src/composables/useTextHighlighter.ts 5/5 Applied the same strict HTTP status code regex pattern in three locations: analyzeSegment function (line 415), and splitTextBySemantic function (line 548). Ensures consistent behavior across all text processing functions.
web/src/composables/useLogsHighlighter.spec.ts 5/5 Added comprehensive test cases covering valid HTTP status codes (100-103, 200-208, 226, 300-308, 400-431, 451, 500-511) and invalid 3-digit numbers (147, 189, 209, etc.) to prevent regression of the bug.
web/src/composables/useTextHighlighter.spec.ts 5/5 Added extensive test coverage for both valid and invalid HTTP status codes, including edge cases and address numbers like "147 test address" that should not be highlighted as status codes.

Sequence Diagram

sequenceDiagram
    participant User
    participant LogsPage
    participant useLogsHighlighter
    participant useTextHighlighter
    participant detectSemanticType

    User->>LogsPage: Views logs containing "147 test address"
    LogsPage->>useLogsHighlighter: colorizedJson(data)
    useLogsHighlighter->>useTextHighlighter: processTextWithHighlights("147 test address")
    useTextHighlighter->>detectSemanticType: detectSemanticType("147")
    
    Note over detectSemanticType: OLD: /^[1-5]\d{2}$/ matches "147" ❌
    Note over detectSemanticType: NEW: Strict pattern rejects "147" ✓
    
    detectSemanticType-->>useTextHighlighter: "default" (not status-code)
    useTextHighlighter-->>useLogsHighlighter: Styled HTML (no red color)
    useLogsHighlighter-->>LogsPage: Rendered HTML
    LogsPage-->>User: "147" displayed in normal color ✓
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.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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