Fix Auto Parse TypeError from invalid OpenCV.js column data#370
Merged
Conversation
Added validation checks to prevent "Cannot create property on number" error: - Validate columns array elements before destructuring - Add safe handling for malformed column data - Replace destructuring assignment with explicit variable assignments - Add validation in reduce operation to handle edge cases Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Improve robustness by validating that column array elements are numbers before performing arithmetic operations. This prevents potential runtime errors from non-numeric values. Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Reduce code duplication by extracting column validation logic into a reusable helper function. This improves maintainability and makes the code more readable. Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Document the validation helper function with JSDoc comments for better code maintainability and developer experience. Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix auto parse failing issue on first page
Fix Auto Parse TypeError from invalid OpenCV.js column data
Dec 16, 2025
Contributor
cubap
approved these changes
Dec 16, 2025
cubap
approved these changes
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto Parse crashes with
TypeError: Cannot create property '3918' on number '1'when OpenCV.js returns malformed column data during text line detection.Changes
Added validation helper
isValidColumn(col)validates array structure and numeric types before destructuringDefensive column merging
columns[0]before accessing elements[[0, binary.cols]]on invalid dataSafe reduce operation
Example
Invalid data now logs warnings and degrades to single-column detection rather than crashing.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.