Skip to content

fix: robust handling of undefined sentences in question generation from OCR/PDF - #15

Open
cto-new[bot] wants to merge 1 commit into
mainfrom
bugfix-pdf-parse-questionbank-undefined-sentence-slice
Open

fix: robust handling of undefined sentences in question generation from OCR/PDF#15
cto-new[bot] wants to merge 1 commit into
mainfrom
bugfix-pdf-parse-questionbank-undefined-sentence-slice

Conversation

@cto-new

@cto-new cto-new Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a runtime bug caused by undefined sentences during question generation from OCR- or PDF-extracted text, ensuring the platform never crashes and provides better error handling for edge cases.

Details

  • Adds null checks and fallback values for all usages of sentence.slice()
  • Validates extracted sentences and keywords arrays before generating questions
  • Improves extractSentences, selectRandomUnused, and related helpers for robust array handling
  • Upgrades error handling with clear user-facing messages when extraction fails
  • Maintains compatibility and resilience during ingestion of sparse or noisy document text

Warning: Task VM test is not passing, cto.new will perform much better if you fix the setup

Fixes a bug where undefined sentences could cause runtime errors during
question generation from extracted PDF or OCR text ("undefined is not an
object (evaluating 'sentence.slice')").

- Adds null/empty checks to sentence.slice() in multiple-choice and
  additional question generation flows
- Improves robustness of extractSentences, selectRandomUnused, and
  generateQuestions with validation and safer fallbacks
- Provides descriptive error messages for extraction failures

This prevents application crashes from poorly-formed or sparse input,
improves error transparency, and ensures a more resilient one-click
question generation experience for the user.
@vercel

vercel Bot commented Nov 6, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ct-otest Ready Ready Preview Comment Nov 6, 2025 2:12pm

@coderabbitai

coderabbitai Bot commented Nov 6, 2025

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Fri Nov 07 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants