FileMaker icon indicating copy to clipboard operation
FileMaker copied to clipboard

Error handling: occasional blank response body

Open gRegorLove opened this issue 4 years ago • 0 comments

This might be more of an issue with FileMaker Server, but I was wondering if this library could be used to handle this edge case better:

Summary: Sometimes FileMaker Server responds to a getLayout with an HTTP 200 and an empty response body. This library then throws an exception while trying to parse the response body.

Environment:

  • FileMaker Server Web Publishing Engine v14.0.4.412
  • airmoi/filemaker v2.2.3
  • PHP 7.3

Request URL: https://fmhost.example.com/fmi/xml/fmresultset.xml?-db=DBNAME&-lay=LAYOUT_NAME&-view

Stack Trace: (relevant parts)

#0 /vendor/airmoi/filemaker/src/Parser/FMResultSet.php(80): airmoi\FileMaker\FileMaker->returnOrThrowException('XML error: Not ...')
#1 /vendor/airmoi/filemaker/src/FileMaker.php(501): airmoi\FileMaker\Parser\FMResultSet->parse('HTTP/1.1 200 OK...')
#2 /site/ready.php(285): airmoi\FileMaker\FileMaker->getLayout('layout_name')

Exception message is: "XML error: Not well-formed (invalid token) at line 1"

Notes: It looks like the HTTP response headers get passed to FMResultSet::parse() in this scenario instead of the empty response body.

I'm not sure the ideal solution here, whether it should return some empty result or throw a FileMakerException before it tries to parse the non-existent XML.

gRegorLove avatar Dec 11 '21 20:12 gRegorLove