← Back to Pull requests

fix(data-editor): prevent YAML block-scalar growth loop on invalid input #3600

Closed
unknown closed this pull request without merging on Sep 28, 2026 22:55 UTC
View on GitHub
unknown unknown commented on Sep 17, 2026 20:09 UTC
Author

Summary

Fixes a critical browser-crash bug in YAML/JSON data editor fields across all AAP product UIs (Controller, PAH, EDA, Gateway).

Root Cause

When valueToObject() received a string that failed both JSON and YAML parsing (e.g. ---\n a: b — an indented document separator copied from a code block), it silently discarded the return value of the inner catchError() helper and returned the raw string as-is. objectToString() then called jsyaml.dump(rawString) which serialised the string as a YAML block scalar:

# Input:  '  ---\n  a: b'
# After one jsyaml.dump() call:
'|2-\n    ---\n    a: b\n'

On the next parse–dump round-trip jsyaml.load() returned the string with an extra level of indentation, and jsyaml.dump() produced an even longer block scalar. Each iteration added 2 characters, so editor content grew unboundedly until the browser tab crashed.

Fix

Replace the catch-and-discard pattern with nested try/catch that propagates parse errors when both JSON and YAML parsing fail. handleChange() displays validation errors without updating the form value, and parseFormat blocks submit. Display-only paths use formatEditorDisplayValue / getValueToObjectParseError so mount, copy, download, and drop do not white-screen.

Affects: https://redhat.atlassian.net/browse/AAP-93178

Type of Change

  • Bug fix
  • Risk Analysis - REQUIRED

  • High — Broad platform impact

  • Medium — Scoped but cross-cutting

  • Low — Narrowly scoped
  • PageFormDataEditor is shared across AWX, Hub, EDA, and Gateway. This PR changes parse/submit behavior (throw on invalid input, parseFormat gating, --- empty markers, copy/download/drop handling) and display sync paths. Blast radius is framework-wide but the diff is focused on the data editor module; valid YAML/JSON inputs behave as before.

    Testing

    Manual Testing

    1. Open any YAML/JSON editor field (e.g. Extra Variables in a Job Template).
    2. Paste or type ---\n a: b (2 spaces before ---).
    3. Before fix: content grows on each render until the tab crashes.
    4. After fix: inline validation error; content stable; Save blocked until fixed.

    JSON mode: space + unclosed ' shows error and blocks save without wiping saved extra vars.

    Unit / E2E

  • PageFormDataEditor.test.tsx regression coverage (parse errors, submit blocking, --- marker, copy/download/drop).

  • job-template-validation.spec.ts (AAP-93178).

  • Constructed inventory source_vars validate uses getValueToObjectParseError so custom rules return parse messages instead of throwing.
  • Before

    https://github.com/user-attachments/assets/c00a4fec-1cb3-4b13-8222-20da25fb6fe2

    After

    https://github.com/user-attachments/assets/ec0906c5-9ef9-4d71-96b7-1a8f04c26f80

    Assisted-by: Claude Sonnet 4.6 (Anthropic)

    Made with Cursor

    Diff: 368 lines (+276 / -92) across 4 files Reviewer: keithjgrant Review duration: 16005m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 368 lines diff across 4 files
    0.43
    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.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3600"
    general weight: 0.35
    Reviewers
    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: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    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: 16.9% · Safe to merge
    16.9%