{"record":{"id":"0ac1aea4b6d7450a","repo":"yorukot/superfile","slug":"failure-in-extracted-content-w","errorCode":null,"errorMessage":"failure in extracted content : %w","messagePattern":"failure in extracted content : %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/internal/validation.go","lineNumber":393,"sourceCode":"\n\t\t// TODO: Add validations for overlay models\n\t}\n\n\treturn nil\n}\n\n// Inclusive\nfunc (m *model) validateComponentPlacement(lines []string, pos compPosition, border bool) error {\n\textractedLines, err := m.extractComponent(lines, pos)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failure while extracting content : %w\", err)\n\t}\n\n\tcntRow := pos.endRow - pos.stRow + 1\n\tcntCol := pos.endCol - pos.stCol + 1\n\textractedOut := strings.Join(extractedLines, \"\\n\")\n\tif err := validateRender(extractedOut, cntRow, cntCol, border); err != nil {\n\t\treturn fmt.Errorf(\"failure in extracted content : %w\", err)\n\t}\n\treturn nil\n}\n\n// Inclusive\nfunc (m *model) extractComponent(lines []string, pos compPosition) ([]string, error) {\n\tif 0 > pos.stRow || pos.stRow > pos.endRow || pos.endRow >= len(lines) {\n\t\treturn nil, fmt.Errorf(\"invalid row range [%v, %v], line count : %v\",\n\t\t\tpos.stRow, pos.endRow, len(lines))\n\t}\n\tfirstLineWidth := ansi.StringWidth(lines[0])\n\tif 0 > pos.stCol || pos.stCol > pos.endCol || pos.endCol >= firstLineWidth {\n\t\treturn nil, fmt.Errorf(\"invalid col range [%v, %v], first line width : %v\",\n\t\t\tpos.stCol, pos.endCol, firstLineWidth)\n\t}\n\n\tcntRow := pos.endRow - pos.stRow + 1\n\textractedLines := make([]string, cntRow)","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/yorukot/superfile/blob/b72f550bc6e75913f48eb49fdd258e1a2df2fe88/src/internal/validation.go#L375-L411","documentation":"After extracting the component region, validateComponentPlacement joins the extracted lines and runs validateRender to confirm the extracted block fits the expected row/column count (and border rules). This error wraps a validateRender failure, meaning the extracted content itself fails dimensional validation — the rendered component occupies a different footprint than declared.","triggerScenarios":"extractedOut has more lines than cntRow, wider content than cntCol, or otherwise violates validateRender's rules (e.g., lines wrapping beyond the allotted width).","commonSituations":"A component's ANSI-styled output wraps to extra lines because its computed width is off by the border width; multi-byte/emoji characters inflate visual width; terminal resize invalidates cached layout metrics.","solutions":["Compare extracted line count/width against cntRow/cntCol in a debug run to see the mismatch","Ensure the component is rendered with the exact same width/height the position was computed for (account for borders)","Use ansi-aware width measurement (ansi.StringWidth) rather than len() when computing positions","Re-render after terminal resize so positions match the current content"],"exampleFix":"// before\nif err := validateRender(extractedOut, cntRow, cntCol, border); err != nil {\n\treturn fmt.Errorf(\"failure in extracted content : %w\", err)\n}\n// after\ncntCol += extraBorderWidth // account for border drawn by component\nif err := validateRender(extractedOut, cntRow, cntCol, border); err != nil {\n\treturn fmt.Errorf(\"failure in extracted content : %w\", err)\n}","handlingStrategy":"validation","validationCode":"extracted := strings.Join(extractedLines, \"\\n\")\nlinesOK := len(extractedLines) == cntRow\nwidthsOK := true\nfor _, l := range extractedLines { if ansi.StringWidth(l) > cntCol { widthsOK = false } }","typeGuard":null,"tryCatchPattern":"if err := validateRender(extractedOut, cntRow, cntCol, border); err != nil {\n\tlog.Printf(\"extracted block %dx%d invalid: %v\", cntRow, cntCol, err)\n\treturn err\n}","preventionTips":["Render components with the exact dimensions used for position computation","Include border widths in cntRow/cntCol when border=true","Test with wide characters (CJK, emoji) to catch width mismatches","Re-render and revalidate after terminal resize events"],"tags":["go","validation","rendering","ansi"],"backgroundTag":"render-size-mismatch","analyzedSha":"b72f550bc6e75913f48eb49fdd258e1a2df2fe88","analyzedAt":"2026-09-01T04:38:08.254Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}