← Back to Pull requests

fix: load JSON streams with integers larger than float64 #1

Closed
a7i closed this pull request without merging on Sep 01, 2026 17:25 UTC
View on GitHub
a7i a7i commented on Sep 01, 2026 13:41 UTC
Author

Summary


  • LoadResources crashed on a JSON stream once an integer larger than float64 appeared after two successfully decoded objects.

  • YAMLOrJSONDecoder's JSON path uses encoding/json without UseNumber. After two objects it does not fall back to YAML, so the next overflow fails with json: cannot unmarshal number ... into Go value of type float64.

  • Frame each document as json.RawMessage (same idea as kubectl's runtime.RawExtension), then parse that one document with utilyaml.Unmarshal. Overflowing integers are kept as strings.
  • Example


    A stream of three JSON objects, with a 705-digit integer on the third:

    {"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"a"},"data":{"value":1}}
    {"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"a"},"data":{"value":1}}
    {"apiVersion":"v1","kind":"ConfigMap","metadata":{"name":"b"},"data":{"value":999...705 nines...999}}
    

    Before: kapt: resources.json: json: cannot unmarshal number 999... into Go value of type float64

    After: all three objects load. data.value on b is the original digit string.

    A single JSON object with the same number already worked, because the decoder could still switch to YAML. Multi-document YAML was also fine. The failure is JSON streams after two objects.

    Test plan


  • go test ./...

  • regression in LoadResources: JSON stream with two small objects, then a 705-digit integer
  • Diff: 24 lines (+22 / -2) across 2 files Reviewer: jklaw90 Review duration: 223m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.24) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.24 · 24 lines diff across 2 files
    0.24
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.72 · 2 substantive comment(s)
    0.72
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    80%
    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.193
    Real PR Conversation Timeline
    6 items
    jklaw90 jklaw90 approved these changes on Sep 01, 2026 14:05 UTC
    Approved Reviewer

    Approved these changes.

    zendesk-robbieobrien zendesk-robbieobrien approved these changes on Sep 01, 2026 14:07 UTC
    Approved Reviewer

    Approved these changes.

    grosser grosser approved these changes on Sep 01, 2026 17:18 UTC
    Approved Reviewer

    super sus usecase but 👍

    grosser grosser commented on Sep 01, 2026 17:25 UTC
    Contributor

    manually merging to fix test coverage

    grosser grosser commented on Sep 01, 2026 17:36 UTC
    Contributor

    v0.4.1

    Reviewers
    Assignees
    a7i a7i
    Labels
    risk: low confidence: 80.7% 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: 23.7% (LOW) · Higher = larger blast radius
    23.7%
    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: 80.7% · Lower = rushed or shallow review
    80.7%
    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: 4.6% · Safe to merge
    4.6%
    Repository