← Back to Pull requests

fix: HistoryServer unit tests failure caused by ID normalization in ConvertBase64ToHex #4769

Closed
unknown closed this pull request without merging on May 05, 2026 14:42 UTC
View on GitHub
unknown unknown commented on Apr 27, 2026 03:41 UTC
Author

<!-- Thank you for your contribution! -->

<!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. -->

Why are these changes needed?

<!-- Please give a short summary of the change and the problem this solves. -->
Several unit tests in pkg/eventserver were failing because test IDs like "task-1", "actor-1", and "ID_12345" were being silently transformed before storage.

normalizeIDToHex calls ConvertBase64ToHex, which:
1. Returns the value unchanged if it matches ^[0-9a-fA-F]+$ (pure hex)
2. Otherwise, attempts raw URL-safe base64 decoding (base64.RawURLEncoding)

https://github.com/ray-project/kuberay/blob/262d0f458af7fc9e820307fa72371acdd8df704a/historyserver/pkg/utils/utils.go#L103-L119

The fact that these non-pure-hex ids would changed can be verified through

cat > /tmp/try_b64.go << 'EOF'
package main

import (
    "fmt"
    "github.com/ray-project/kuberay/historyserver/pkg/utils"
)

func main() {
    inputStr := "task-1"
    result, err := utils.ConvertBase64ToHex(inputStr)
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Printf("Input: %s, Result: %s\n", inputStr, result)
}
EOF

go run /tmp/try_b64.go

Affected tests:

  • TestMultipleReprocessingCycles — panicked with index out of range [0] with length 0

  • TestTaskLifecycleEventDeduplication

  • TestActorLifecycleEventDeduplication

  • TestStoreEvent

  • TestEventProcessor
  • Test Environment


    The test before and after fix has been run on
    1. Apple M3 (Arm) + Go 1.25.0
    2. Intel Broadwell (x86_64) + Go 1.25.0

    Fix

    Replace all test IDs with pure hex strings (e.g. "AAaaFFff1234"), which match the ^[0-9a-fA-F]+$ pattern in ConvertBase64ToHex and are returned unchanged. No production code or test logic is modified.

    Related issue number

    <!-- For example: "Closes #1234" -->

    Checks

  • I've made sure the tests are passing.

  • Testing Strategy

  • - [x] Unit tests
    - [ ] Manual tests
    - [ ] This PR is not tested :(

    Diff: 266 lines (+199 / -67) across 3 files Reviewer: JiangJiaWei1103 Review duration: 12180m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 266 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.334
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4769"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17% · Safe to merge
    17%