Page MenuHomePhabricator

Wikimedia\Assert\PreconditionException: Precondition failed: Range is not collapsed (from CommentUtils::isSingleCommentSignedBy)
Closed, ResolvedPublic

Description

Seeing this again in 1.39.0-wmf.2 (T300203):

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\PreconditionException: Precondition failed: Range is not collapsed
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.2/vendor/wikimedia/assert/src/Assert.php(49)
#0 /srv/mediawiki/php-1.39.0-wmf.2/extensions/DiscussionTools/includes/CommentUtils.php(552): Wikimedia\Assert\Assert::precondition(boolean, string)
#1 /srv/mediawiki/php-1.39.0-wmf.2/extensions/DiscussionTools/includes/CommentUtils.php(663): MediaWiki\Extension\DiscussionTools\CommentUtils::getRangeFirstNode(MediaWiki\Extension\DiscussionTools\ImmutableRange)
#2 /srv/mediawiki/php-1.39.0-wmf.2/extensions/DiscussionTools/includes/CommentUtils.php(609): MediaWiki\Extension\DiscussionTools\CommentUtils::compareRangesAlmostEqualBoundaries(MediaWiki\Extension\DiscussionTools\ImmutableRange, MediaWiki\Extension\DiscussionTools\ImmutableRange, string)
#3 /srv/mediawiki/php-1.39.0-wmf.2/extensions/DiscussionTools/includes/CommentUtils.php(739): MediaWiki\Extension\DiscussionTools\CommentUtils::compareRanges(MediaWiki\Extension\DiscussionTools\ImmutableRange, MediaWiki\Extension\DiscussionTools\ImmutableRange)
#4 /srv/mediawiki/php-1.39.0-wmf.2/extensions/DiscussionTools/includes/ApiDiscussionToolsPreview.php(61): MediaWiki\Extension\DiscussionTools\CommentUtils::isSingleCommentSignedBy(MediaWiki\Extension\DiscussionTools\ThreadItemSet, string, Wikimedia\Parsoid\DOM\Element)
#5 /srv/mediawiki/php-1.39.0-wmf.2/includes/api/ApiMain.php(1893): MediaWiki\Extension\DiscussionTools\ApiDiscussionToolsPreview->execute()
#6 /srv/mediawiki/php-1.39.0-wmf.2/includes/api/ApiMain.php(870): ApiMain->executeAction()
#7 /srv/mediawiki/php-1.39.0-wmf.2/includes/api/ApiMain.php(841): ApiMain->executeActionWithErrorHandling()
#8 /srv/mediawiki/php-1.39.0-wmf.2/api.php(90): ApiMain->execute()
#9 /srv/mediawiki/php-1.39.0-wmf.2/api.php(45): wfApiMain()
#10 /srv/mediawiki/w/api.php(3): require(string)
#11 {main}

I'm making a separate task because the stack trace is different, This exception is coming from the newly introduced method CommentUtils::isSingleCommentSignedBy() (added in rEDTO0ecc8a4c051d: Improve detecting already signed comments).

Event Timeline

Also it looks like there are only 8 occurrences in total, so it doesn't seem like a train blocker.

I can reproduce the error by trying to preview (or add) a new topic with a heading containing only space characters (but not empty).

Change 772521 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] CommentUtils: Fix isSingleCommentSignedBy() with empty heading

https://gerrit.wikimedia.org/r/772521

Change 772521 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] CommentUtils: Fix isSingleCommentSignedBy() with empty heading

https://gerrit.wikimedia.org/r/772521

I can reproduce the error by trying to preview (or add) a new topic with a heading containing only space characters (but not empty).

I forgot to note: the error causes the live preview to stop updating, and an error message like below when trying to add the topic:

image.png (1×3 px, 160 KB)

(I won't bother backporting the fix, because of the daily the train experiment it should be deployed tomorrow.)

Live preview updates fine and I am able to add topic. See

Screenshot 2022-03-23 at 00.57.41.png (952×2 px, 130 KB)

Screenshot 2022-03-23 at 01.03.32.png (1×1 px, 162 KB)