fix(data-editor): prevent YAML block-scalar growth loop on invalid input #3600
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
keithjgrant
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 innercatchError()helper and returned the raw string as-is.objectToString()then calledjsyaml.dump(rawString)which serialised the string as a YAML block scalar:On the next parse–dump round-trip
jsyaml.load()returned the string with an extra level of indentation, andjsyaml.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, andparseFormatblocks submit. Display-only paths useformatEditorDisplayValue/getValueToObjectParseErrorso mount, copy, download, and drop do not white-screen.Affects: https://redhat.atlassian.net/browse/AAP-93178
Type of Change
Risk Analysis - REQUIRED
PageFormDataEditoris shared across AWX, Hub, EDA, and Gateway. This PR changes parse/submit behavior (throw on invalid input,parseFormatgating,---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.tsxregression coverage (parse errors, submit blocking,---marker, copy/download/drop).job-template-validation.spec.ts(AAP-93178).source_varsvalidate usesgetValueToObjectParseErrorso 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