Skip to content

Conversation

@hengfeiyang
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Failed to generate code suggestions for PR

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

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

Fixed a critical array index out-of-bounds panic in the create_wal_dir_datetime_filter function. The month_days array is 0-indexed (indices 0-11) but was being accessed with month values ranging from 1-12, causing a panic when processing December (month=12).

Key Changes:

  • Changed month_days[month as usize] to month_days[(month-1) as usize] on line 202
  • This prevents array index out-of-bounds panic when filtering WAL directory paths with December dates
  • The fix is minimal, correct, and directly addresses the root cause of the panic

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix is a single-character change that correctly addresses a critical off-by-one indexing error. The month_days array has 12 elements (indices 0-11), and month values range from 1-12, so subtracting 1 before indexing is the correct solution. The existing tests validate the datetime filtering logic, and this change prevents the panic that would occur when processing December dates.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/config/src/utils/async_file.rs 5/5 Fixed critical array out-of-bounds panic when accessing month_days array with month value 12

Sequence Diagram

sequenceDiagram
    participant Caller
    participant create_wal_dir_datetime_filter
    participant Filter Closure
    participant month_days Array

    Caller->>create_wal_dir_datetime_filter: Call with start_time, end_time, extension, skip_count
    create_wal_dir_datetime_filter->>Filter Closure: Create filter closure
    
    loop For each path
        Caller->>Filter Closure: Call with PathBuf
        Filter Closure->>Filter Closure: Parse year from path
        Filter Closure->>Filter Closure: Parse month (1-12) from path
        Filter Closure->>month_days Array: Access month_days[(month-1)]
        Note over Filter Closure,month_days Array: Fixed: month-1 prevents panic<br/>when month=12 (Dec)
        month_days Array-->>Filter Closure: Return days in month
        Filter Closure->>Filter Closure: Validate day against days in month
        Filter Closure->>Filter Closure: Parse hour and check date range
        Filter Closure-->>Caller: Return true/false
    end
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.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@hengfeiyang hengfeiyang merged commit 987fd11 into branch-v0.20.0 Dec 1, 2025
9 of 10 checks passed
@hengfeiyang hengfeiyang deleted the hotfix/search-wal branch December 1, 2025 01:40
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