documentation: Inconsistent responses when PUTting media

Creating media via HTTP PUT (docs) sometimes returns a 201 and sometimes returns a 204. Does anybody know why this is? One practical implication of this is that when Drupal responds with a 201, a location header is returned:

{'Date': 'Mon, 06 Apr 2020 15:38:20 GMT', 'Server': 'Apache/2.4.29 (Ubuntu)', 'X-Powered-By': 'PHP/7.2.29-1+ubuntu18.04.1+deb.sury.org+1', 'Cache-Control': 'must-revalidate, no-cache, private', 'Location': 'http://localhost:8000/media/193', 'X-UA-Compatible': 'IE=edge', 'Content-language': 'en', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Expires': 'Sun, 19 Nov 1978 05:00:00 GMT', 'Vary': '', 'X-Generator': 'Drupal 8 (https://www.drupal.org)', 'Content-Length': '0', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive', 'Content-Type': 'text/html; charset=UTF-8'}

But when a 204 is returned, there is no location:

{'Date': 'Mon, 06 Apr 2020 15:38:24 GMT', 'Server': 'Apache/2.4.29 (Ubuntu)', 'X-Powered-By': 'PHP/7.2.29-1+ubuntu18.04.1+deb.sury.org+1', 'Cache-Control': 'must-revalidate, no-cache, private', 'X-UA-Compatible': 'IE=edge', 'Content-language': 'en', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Expires': 'Sun, 19 Nov 1978 05:00:00 GMT', 'Vary': '', 'X-Generator': 'Drupal 8 (https://www.drupal.org)', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive'}

In both cases, the media appears to be created.

Some poking around in source code has led me to https://github.com/Islandora/islandora/blob/8.x-1.x/src/Controller/MediaSourceController.php#L143 as the source of this behavior but I am not clear on what triggers success or non-success. In both cases, the media appear to be created.

@dannylamb can you shed some light on this? Or any other @Islandora/8-x-committers ?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 32 (32 by maintainers)

Most upvoted comments

Ok, got something, I think: I’ve created about 100 media and didn’t get any 204s but I did get a 500, so looked in my apache error log. Found these:

sudo tail -f  /var/log/apache2/error.log
[Mon Apr 06 20:36:18.096001 2020] [php7:notice] [pid 8883] [client 127.0.0.1:45908] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:36:52.072608 2020] [php7:notice] [pid 9828] [client 127.0.0.1:46514] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:38:04.491148 2020] [php7:notice] [pid 9933] [client 127.0.0.1:47504] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:38:22.265251 2020] [php7:notice] [pid 10494] [client 127.0.0.1:47988] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:38:54.089959 2020] [php7:notice] [pid 9758] [client 127.0.0.1:48798] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:39:19.224328 2020] [php7:notice] [pid 6980] [client 127.0.0.1:49276] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:39:22.099831 2020] [php7:notice] [pid 9758] [client 127.0.0.1:49398] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:40:28.160379 2020] [php7:notice] [pid 9933] [client 10.0.2.2:49474] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:40:45.711832 2020] [php7:notice] [pid 9758] [client 127.0.0.1:51126] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:41:13.480497 2020] [php7:notice] [pid 11151] [client 10.0.2.2:49554] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:41:49.633085 2020] [php7:notice] [pid 11136] [client 127.0.0.1:52186] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT savepoint_1 does not exist: ROLLBACK TO SAVEPOINT savepoint_1; Array\n(\n)\n" at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192
[Mon Apr 06 20:41:57.430145 2020] [php7:notice] [pid 10047] [client 127.0.0.1:52274] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\HttpException: "'field_config' entity with ID 'media.fits_technical_metadata.fits_exiftool_exposure_time' already exists." at /var/www/html/drupal/web/modules/contrib/islandora/src/Controller/MediaSourceController.php line 192

Strange thing is, they don’t correspond to 500s I was seeing as a result of my REST PUT calls, but they are all being thrown at MediaSourceController.php line 192.

I’m not sure if it will matter, I just noticed that it wasn’t being explicitly closed.

I’ll do some logging to see if I can come up with any more information.

Is it reasonable to assume that if the controller generates a 204, the media already has a URL (i.e., a /media/xxx URL?

@whikloj that is my understanding too but I am seeing this when creating new media.They don’t already exists.