Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status code 500 when getting robots.txt #1698

Closed
acidmoose opened this issue Feb 10, 2023 · 4 comments · Fixed by #1699
Closed

Status code 500 when getting robots.txt #1698

acidmoose opened this issue Feb 10, 2023 · 4 comments · Fixed by #1699
Labels
Milestone

Comments

@acidmoose
Copy link

Thanks for the efforts put into this awesome piece of software. It has served us well over the last few years, but lately we've been noticing some logs that we started looking into. The issue is quickly reproducable on localhost using the docker image.

How Shlink is set up

  • Shlink Version: 3.4.0
  • How do you serve Shlink: Docker image on localhost
  • Database engine used: Nothing outside of the standard docker image

Summary

Shlink fails with internal errors when trying to fetch robots.txt, even from basic setup on localhost.

Affected versions

Version 3.4.0 and above, including current stable 3.5.1.
Version 3.3.2 and below does not have this behavior.

Current behavior

The issue is causing shlink to respond with the status code 500.

Expected behavior

Show the proper response as it used to in earlier versions.

How to reproduce

Start with docker based on Getting Started docs.

docker run \
    --rm \
    --name my_shlink \
    -p 8080:8080 \
    -e DEFAULT_DOMAIN=s.test \
    -e IS_HTTPS_ENABLED=false \
    shlinkio/shlink:3.4.0
curl localhost:8080/robots.txt

Change to shlinkio/shlink:3.3.2 and it works again.

Stacktrace from shlink:

[2023-02-10T09:09:29.430969+00:00] [4f17ad13-2a38-4d1a-9f3c-e41ce7b4b39e] Shlink.ERROR - TypeError: Shlinkio\Shlink\Core\Crawling\CrawlingHelper::__construct(): Argument #1 ($query) must be of type Shlinkio\Shlink\Core\ShortUrl\Repository\CrawlableShortCodesQueryInterface, Shlinkio\Shlink\Common\Doctrine\ReopeningEntityManager given, called in /etc/shlink/vendor/laminas/laminas-servicemanager/src/AbstractFactory/ConfigAbstractFactory.php on line 76 and defined in /etc/shlink/module/Core/src/Crawling/CrawlingHelper.php:11
Stack trace:
#0 /etc/shlink/vendor/laminas/laminas-servicemanager/src/AbstractFactory/ConfigAbstractFactory.php(76): Shlinkio\Shlink\Core\Crawling\CrawlingHelper->__construct(Object(Shlinkio\Shlink\Common\Doctrine\ReopeningEntityManager))
#1 /etc/shlink/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(620): Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'Shlinkio\\Shlink...', NULL)
#2 /etc/shlink/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(242): Laminas\ServiceManager\ServiceManager->doCreate('Shlinkio\\Shlink...')
#3 [internal function]: Laminas\ServiceManager\ServiceManager->get('Shlinkio\\Shlink...')
#4 /etc/shlink/vendor/laminas/laminas-servicemanager/src/AbstractFactory/ConfigAbstractFactory.php(74): array_map(Array, Array)
#5 /etc/shlink/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(620): Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'Shlinkio\\Shlink...', NULL)
#6 /etc/shlink/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(242): Laminas\ServiceManager\ServiceManager->doCreate('Shlinkio\\Shlink...')
#7 /etc/shlink/vendor/mezzio/mezzio/src/MiddlewareContainer.php(52): Laminas\ServiceManager\ServiceManager->get('Shlinkio\\Shlink...')
#8 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\MiddlewareContainer->get('Shlinkio\\Shlink...')
#9 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#10 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#11 /etc/shlink/vendor/mezzio/mezzio-router/src/Route.php(85): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#12 /etc/shlink/vendor/mezzio/mezzio-router/src/RouteResult.php(97): Mezzio\Router\Route->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#13 /etc/shlink/vendor/mezzio/mezzio-router/src/Middleware/DispatchMiddleware.php(30): Mezzio\Router\RouteResult->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#14 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Mezzio\Router\Middleware\DispatchMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#15 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#16 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#17 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#18 /etc/shlink/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#19 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#20 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#21 /etc/shlink/vendor/mezzio/mezzio-router/src/Middleware/ImplicitHeadMiddleware.php(76): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#22 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Mezzio\Router\Middleware\ImplicitHeadMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#23 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#24 /etc/shlink/vendor/mezzio/mezzio-router/src/Middleware/RouteMiddleware.php(50): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#25 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Mezzio\Router\Middleware\RouteMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#26 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#27 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#28 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#29 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#30 /etc/shlink/vendor/shlinkio/shlink-common/src/Middleware/CloseDbConnectionMiddleware.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#31 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Shlinkio\Shlink\Common\Middleware\CloseDbConnectionMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#32 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#33 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#34 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#35 /etc/shlink/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#36 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#37 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#38 /etc/shlink/module/Rest/src/Middleware/CrossDomainMiddleware.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#39 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#40 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#41 /etc/shlink/vendor/laminas/laminas-stratigility/src/Middleware/ErrorHandler.php(129): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#42 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Laminas\Stratigility\Middleware\ErrorHandler->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#43 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#44 /etc/shlink/vendor/php-middleware/request-id/src/RequestIdMiddleware.php(32): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#45 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): PhpMiddleware\RequestId\RequestIdMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#46 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#47 /etc/shlink/vendor/shlinkio/shlink-common/src/Middleware/ContentLengthMiddleware.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#48 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(27): Shlinkio\Shlink\Common\Middleware\ContentLengthMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#49 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#50 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#51 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#52 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#53 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(64): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\EmptyPipelineHandler))
#54 /etc/shlink/vendor/mezzio/mezzio-swoole/src/Event/RequestHandlerRequestListener.php(109): Laminas\Stratigility\MiddlewarePipe->handle(Object(Laminas\Diactoros\ServerRequest))
#55 /etc/shlink/vendor/mezzio/mezzio-swoole/src/Event/EventDispatcher.php(36): Mezzio\Swoole\Event\RequestHandlerRequestListener->__invoke(Object(Mezzio\Swoole\Event\RequestEvent))
#56 /etc/shlink/vendor/mezzio/mezzio-swoole/src/SwooleRequestHandlerRunner.php(147): Mezzio\Swoole\Event\EventDispatcher->dispatch(Object(Mezzio\Swoole\Event\RequestEvent))
#57 [internal function]: Mezzio\Swoole\SwooleRequestHandlerRunner->onRequest(Object(Swoole\Http\Request), Object(Swoole\Http\Response))
#58 {main}
[2023-02-10T09:09:29.433473+00:00] [4f17ad13-2a38-4d1a-9f3c-e41ce7b4b39e] Access.ERROR - - "GET /robots.txt HTTP/1.1" 500 28
@acidmoose acidmoose added the bug label Feb 10, 2023
@acelaya
Copy link
Member

acelaya commented Feb 10, 2023

Thanks for reporting

@acelaya acelaya added this to the 3.5.2 milestone Feb 10, 2023
@acelaya acelaya added this to Shlink Feb 10, 2023
@acelaya acelaya moved this to Todo 🗒️ in Shlink Feb 10, 2023
@acelaya acelaya moved this from Todo 🗒️ to In Progress 📝 in Shlink Feb 10, 2023
@acelaya acelaya moved this from In Progress 📝 to In review 👀 in Shlink Feb 10, 2023
@acelaya
Copy link
Member

acelaya commented Feb 10, 2023

I have just fixed this and added a new test that would have caught it much earlier.

Thanks again for the heads-up!

@github-project-automation github-project-automation bot moved this from In review 👀 to Done ✅ in Shlink Feb 10, 2023
@acelaya
Copy link
Member

acelaya commented Feb 17, 2023

Shlink 3.5.2 was released yesterday, including this fix.

@acidmoose
Copy link
Author

@acelaya Thanks for the quick fix and release. Works perfectly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants