doctrine / rst-parser

MIT License
59 stars 23 forks source link

A fatal error related to some table parsing #157

Closed javiereguiluz closed 1 year ago

javiereguiluz commented 3 years ago

Hi all! I'm building Symfony Docs with this RST parser and I'm facing a fatal error. It's hard to know the exact reason for the error, but after debugging a bit, this is the information I have.

1) The problem happens when parsing this file: https://raw.githubusercontent.com/symfony/symfony-docs/5.4/mailer.rst

2) The problem is related to some table because the error trace says:

Warning: Undefined array key -1

  #0 vendor/doctrine/rst-parser/lib/Nodes/TableNode.php(188): Doctrine\RST\Nodes\TableNode->compileSimpleTable()
  #1 vendor/doctrine/rst-parser/lib/Nodes/TableNode.php(148): Doctrine\RST\Nodes\TableNode->compile()
  #2 vendor/doctrine/rst-parser/lib/Parser/DocumentParser.php(570): Doctrine\RST\Nodes\TableNode->finalize(Object(Doctrine\RST\Parser))
  #3 vendor/doctrine/rst-parser/lib/Parser/DocumentParser.php(359): Doctrine\RST\Parser\DocumentParser->flush()
  #4 vendor/doctrine/rst-parser/lib/Parser/DocumentParser.php(213): Doctrine\RST\Parser\DocumentParser->parseLine('')
  #5 vendor/doctrine/rst-parser/lib/Parser/DocumentParser.php(150): Doctrine\RST\Parser\DocumentParser->parseLines('\nSending Emails...')
  #6 vendor/doctrine/rst-parser/lib/Parser.php(178): Doctrine\RST\Parser\DocumentParser->parse('Sending Emails ...')
  #7 vendor/doctrine/rst-parser/lib/Parser.php(162): Doctrine\RST\Parser->parseLocal('Sending Emails ...')
  #8 vendor/doctrine/rst-parser/lib/Parser.php(200): Doctrine\RST\Parser->parse('Sending Emails ...')
  #9 vendor/doctrine/rst-parser/lib/Builder/ParseQueueProcessor.php(71): Doctrine\RST\Parser->parseFile('/Users/javier/w...')
  #10 vendor/doctrine/rst-parser/lib/Builder/ParseQueueProcessor.php(59): Doctrine\RST\Builder\ParseQueueProcessor->processFile('mailer')
  #11 vendor/doctrine/rst-parser/lib/Builder.php(227): Doctrine\RST\Builder\ParseQueueProcessor->process(Object(Doctrine\RST\Builder\ParseQueue))
  #12 vendor/doctrine/rst-parser/lib/Builder.php(164): Doctrine\RST\Builder->parse('/Users/javier/w...', '/Users/javier/w...', Object(Doctrine\RST\Builder\ParseQueue))
  #13 vendor/symfony-tools/docs-builder/src/DocBuilder.php(27): Doctrine\RST\Builder->build('/Users/javier/w...', '/Users/javier/w...')

3) I've narrowed down the problem to this line:

https://github.com/doctrine/rst-parser/blob/b692368c5e275dbda63f5521bc1dae74672933f5/lib/Nodes/TableNode.php#L216

4) After adding a dump($this->rawDataLines); I see this in the console:

^ array:7 [
  1 => "DSN protocol  Example                                   Description"
  3 => "smtp          ``smtp://user:pass@smtp.example.com:25``  Mailer uses an SMTP server to send emails"
  4 => "sendmail      ``sendmail://default``                    Mailer uses the local sendmail binary to send emails"
  5 => "native        ``native://default``                      Mailer uses the sendmail binary and options configured"
  6 => "                                                        in the ``sendmail_path`` setting of ``php.ini``. On Windows"
  7 => "                                                        hosts, Mailer fallbacks to ``smtp`` and ``smtp_port``"
  8 => "                                                        ``php.ini`` settings when ``sendmail_path`` is not configured."
]

^ array:10 [
  1 => "Service             Install with"
  3 => "Amazon SES          ``composer require symfony/amazon-mailer``"
  4 => "Gmail               ``composer require symfony/google-mailer``"
  5 => "MailChimp           ``composer require symfony/mailchimp-mailer``"
  6 => "Mailgun             ``composer require symfony/mailgun-mailer``"
  7 => "Mailjet             ``composer require symfony/mailjet-mailer``"
  8 => "Postmark            ``composer require symfony/postmark-mailer``"
  9 => "SendGrid            ``composer require symfony/sendgrid-mailer``"
  10 => "Sendinblue          ``composer require symfony/sendinblue-mailer``"
  11 => "OhMySMTP            ``composer require symfony/oh-my-smtp-mailer``"
]

^ []

There's an empty table, but I don't know where it comes from.

Thanks!

javiereguiluz commented 3 years ago

I'm seeing the exact same error in other pages with tables:

linawolf commented 1 year ago

@javiereguiluz is this solved by now? Could you provide a failing test?

linawolf commented 1 year ago

I tried creating tests from the exact examples you posted above but can reproduce no error. Maybe this is solved and can be closed?

javiereguiluz commented 1 year ago

Lina, thanks a lot for taking care of reviewing and trying to reproduce this bug. We no longer see it in Symfony Docs and you can't reproduce it, so let's close this as fixed. Thanks!