Page MenuHomePhabricator

InvalidTiffException: Could not extract data from tiff file {filename}
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   InvalidTiffException: Could not extract data from tiff file {filename}
FrameLocationCall
from/srv/mediawiki/php-1.45.0-wmf.1/includes/media/BitmapMetadataHandler.php(298)
#0/srv/mediawiki/php-1.45.0-wmf.1/extensions/PagedTiffHandler/includes/PagedTiffImage.php(194)BitmapMetadataHandler::Tiff(string)
#1/srv/mediawiki/php-1.45.0-wmf.1/extensions/PagedTiffHandler/includes/PagedTiffHandler.php(601)MediaWiki\Extension\PagedTiffHandler\PagedTiffImage->retrieveMetaData()
#2/srv/mediawiki/php-1.45.0-wmf.1/includes/media/MediaHandler.php(230)MediaWiki\Extension\PagedTiffHandler\PagedTiffHandler->getSizeAndMetadata(TrivialMediaHandlerState, string)
#3/srv/mediawiki/php-1.45.0-wmf.1/includes/utils/MWFileProps.php(91)MediaHandler->getSizeAndMetadataWithFallback(Wikimedia\FileBackend\FSFile\FSFile, string)
#4/srv/mediawiki/php-1.45.0-wmf.1/includes/upload/UploadBase.php(589)MWFileProps->getPropsFromPath(string, string)
#5/srv/mediawiki/php-1.45.0-wmf.1/includes/upload/UploadBase.php(514)UploadBase->verifyPartialFile()
#6/srv/mediawiki/php-1.45.0-wmf.1/includes/upload/UploadBase.php(437)UploadBase->verifyFile()
#7/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiUpload.php(822)UploadBase->verifyUpload()
#8/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiUpload.php(159)MediaWiki\Api\ApiUpload->verifyUpload()
#9/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiMain.php(2010)MediaWiki\Api\ApiUpload->execute()
#10/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiMain.php(948)MediaWiki\Api\ApiMain->executeAction()
#11/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiMain.php(919)MediaWiki\Api\ApiMain->executeActionWithErrorHandling()
#12/srv/mediawiki/php-1.45.0-wmf.1/includes/api/ApiEntryPoint.php(152)MediaWiki\Api\ApiMain->execute()
#13/srv/mediawiki/php-1.45.0-wmf.1/includes/MediaWikiEntryPoint.php(198)MediaWiki\Api\ApiEntryPoint->execute()
#14/srv/mediawiki/php-1.45.0-wmf.1/api.php(44)MediaWiki\MediaWikiEntryPoint->run()
#15/srv/mediawiki/w/api.php(3)require(string)
#16{main}
Impact
Notes

Error handling introduced in early April 2025 via "media: Normalize file names in Tiff exceptions" in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/42b3aa3a88515ceab18de4b463431b494689b167%5E%21/includes/media/BitmapMetadataHandler.php by @taavi.
Maybe this is all intentional (useful feedback given to a user trying to upload a TIFF file and wondering why it fails) and should be declined (though I wonder if we could avoid having this propoagated into Logstash).
Still filing this ticket for the papertrail so we'd have a decision record in any case.

Details

MediaWiki Version
1.45.0-wmf.1
Request URL
https://commons.wikimedia.org/w/api.php
Related Changes in Gerrit:

Event Timeline

From the task description:

The above link reports the underlying issue in the shellbox "exec" channel (right before, during the same request):

context.command
/bin/bash '/srv/app/src/Command/limit.sh' ''\''/bin/bash'\'' '\''scripts/retrieveMetaData.sh'\''' 'SB_INCLUDE_STDERR=;SB_CPU_LIMIT=50; SB_CGROUP='\'''\''; SB_MEM_LIMIT=1073741824; SB_FILE_SIZE_LIMIT=536870912; SB_WALL_CLOCK_LIMIT=60; SB_USE_LOG_PIPE=yes'
context.api_client_user_agent
Spacemedia/0.5.0-SNAPSHOT (https://commons.wikimedia.org/wiki/Commons:Spacemedia - OptimusPrimeBot) SpringBoot/3.4.5 ScribeJava/8.3.3 Flickr4Java/3.0.9
context.error
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34736 (0x87b0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.

Tagging per mw:Maintainers.

The impact today is that this Tiff file cannot be uploaded to Wikimedia Commons, and the user receives an unhelpful "Internal server error".

The main question here is: Is this particular Tiff metadata intentionally hard-required during upload? That is, we consider it an invalid Tiff file without this?

If yes, we should catch the exception and tell the user why and what they can do about it.

If not, we should not throw exception, and log a diagnostic warning to Logstash visible to maintainers, without preventing the upload itself.

Change #1174810 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/PagedTiffHandler@master] Catch InvalidTiffException when extract exif data from tiff files

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

Untagging content transform team WIP from needs investigation because there is a patch for the issue.
Thanks @Umherirrender

Change #1174810 merged by jenkins-bot:

[mediawiki/extensions/PagedTiffHandler@master] Catch InvalidTiffException when extract exif data from tiff files

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