Page MenuHomePhabricator

Wikimedia\Assert\PostconditionException: Postcondition failed: makeTitleSafe() should always return a Title for the text returned by getRootText()
Closed, DuplicatePublic

Description

We ran into this error in T315510. Fairly rare, 223 hits in last 90 days: https://logstash.wikimedia.org/goto/e109fec04480df8d4191f8199936a29c

Error comes from Title::getRootTitle(): https://gerrit.wikimedia.org/g/mediawiki/core/+/e98fd01c986f7e84bbb56b16039910f940a08d28/includes/title/Title.php#2004

	public function getRootTitle() {
		$title = self::makeTitleSafe( $this->mNamespace, $this->getRootText() );
		Assert::postcondition(
			$title !== null,
			'makeTitleSafe() should always return a Title for the text returned by getRootText().'
		);
		return $title;
	}

The postcondition is not actually guaranteed.

The simplest counterexample is the title User:. /Foo, which is valid, but getRootText() returns User:., which is not valid. You can find other counterexamples in the Logstash search.

Furthermore, it will fail if the original title has been constructed as invalid, using e.g. Title::makeTitle().