← Back to Pull requests

fix: use VALIDATION_ERROR for invalid model ID in estimate_resources #258

Closed
unknown closed this pull request without merging on Oct 02, 2026 19:20 UTC
View on GitHub
unknown unknown commented on Sep 17, 2026 15:50 UTC
Author

Description

Problem

estimate_resources() in kubeflow_mcp/trainer/api/planning.py returns ErrorCode.SDK_ERROR for invalid model IDs (e.g., "random gibberish"). It should return VALIDATION_ERROR instead.

AI agents interpret SDK_ERROR as a transient backend failure and retry the same bad input, instead of fixing it.

Other validations in the same function (num_workers, batch_size, quantization) correctly use VALIDATION_ERROR.

Fix

_get_model_info_from_hf() now tags errors caused by the model ID itself with an explicit kind, and estimate_resources() maps that to the error code instead of matching the message text:

  • Malformed model ID (kind: "format") → VALIDATION_ERROR

  • Repo the Hub confirms missing with a 404 (kind: "not_found") → VALIDATION_ERROR

  • 401 responses, gated repos, and API/network failures → SDK_ERROR (unchanged)
  • A 401 keeps SDK_ERROR on purpose. The Hub returns it both for a missing repo requested anonymously and for a private repo, so the two cannot be told apart, and an access failure must not be reported as bad input.

    The existing "did you mean" suggestion logic is preserved.

    Tests

    Added regression tests:

  • test_estimate_resources_returns_validation_error_for_invalid_format

  • test_estimate_resources_returns_validation_error_for_confirmed_404

  • test_estimate_resources_keeps_sdk_error_for_access_failures (401 and gated repo)

  • test_estimate_resources_keeps_sdk_error_for_anonymous_401 (live anonymous 401 response shape)

  • test_estimate_resources_returns_sdk_error_for_api_failure
  • All 27 tests in planning_test.py pass. Lint and format checks pass.

    Closes #257

    Diff: 214 lines (+160 / -54) across 2 files Reviewer: abhijeet-dhumal Review duration: 21810m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 214 lines diff across 2 files
    0.37
    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%
    60%
    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.321
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #258"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 14.4% · Safe to merge
    14.4%