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

Unsupported scheme error #2060

Closed
Zernov-A opened this issue Mar 15, 2024 · 3 comments · Fixed by #2063
Closed

Unsupported scheme error #2060

Zernov-A opened this issue Mar 15, 2024 · 3 comments · Fixed by #2063
Labels
Milestone

Comments

@Zernov-A
Copy link

Shlink version

4.0.2

PHP version

?

How do you serve Shlink

Docker image

Database engine

PostgreSQL

Database version

16.2.0

Current behavior

Since Shlink version 4.0.0, URLs with schemas other than http or https have stopped working.
I created short url for viber://pa?chatURI=****. When attempting to open this short url, I receive a 500 response status.
In the Shlink logs, the following error is reported:
Unsupported scheme "viber"; must be any empty string or in the set (http, https) in /etc/shlink/vendor/laminas/laminas-diactoros/src/Uri.php:476

Full stacktrace:

2024-03-15T11:57:32+0000        INFO    server          [2024-03-15T11:57:32.227878+00:00] [311116c4-6864-4715-a255-4c0722073040] Shlink.ERROR - Laminas\Diactoros\Exception\InvalidArgumentException: Unsupported scheme "viber"; must be any empty string or in the set (http, https) in /etc/shlink/vendor/laminas/laminas-diactoros/src/Uri.php:476
Stack trace:
#0 /etc/shlink/vendor/laminas/laminas-diactoros/src/Uri.php(394): Laminas\Diactoros\Uri->filterScheme('viber')
#1 /etc/shlink/vendor/laminas/laminas-diactoros/src/Uri.php(86): Laminas\Diactoros\Uri->parseUri('viber://pa?chat...')
#2 /etc/shlink/module/Core/src/ShortUrl/Helper/ShortUrlRedirectionBuilder.php(30): Laminas\Diactoros\Uri->__construct('viber://pa?chat...')
#3 /etc/shlink/module/Core/src/Action/RedirectAction.php(29): Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlRedirectionBuilder->buildShortUrlRedirect(Object(Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl), Object(Laminas\Diactoros\ServerRequest))
#4 /etc/shlink/module/Core/src/Action/AbstractTrackingAction.php(35): Shlinkio\Shlink\Core\Action\RedirectAction->createSuccessResp(Object(Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl), Object(Laminas\Diactoros\ServerRequest))
#5 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Core\Action\AbstractTrackingAction->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#6 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#7 /etc/shlink/module/Core/src/ShortUrl/Middleware/TrimTrailingSlashMiddleware.php(25): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#8 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Core\ShortUrl\Middleware\TrimTrailingSlashMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#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/akrabat/ip-address-middleware/src/IpAddress.php(132): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#11 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): RKA\Middleware\IpAddress->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#12 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#13 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#14 /etc/shlink/vendor/mezzio/mezzio-router/src/Route.php(79): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#15 /etc/shlink/vendor/mezzio/mezzio-router/src/RouteResult.php(109): Mezzio\Router\Route->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#16 /etc/shlink/vendor/mezzio/mezzio-router/src/Middleware/DispatchMiddleware.php(32): Mezzio\Router\RouteResult->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#17 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\DispatchMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#18 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#19 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#20 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#21 /etc/shlink/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#22 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#23 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#24 /etc/shlink/vendor/mezzio/mezzio-router/src/Middleware/ImplicitHeadMiddleware.php(77): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#25 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\ImplicitHeadMiddleware->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/mezzio/mezzio-router/src/Middleware/RouteMiddleware.php(50): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#28 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\RouteMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#29 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#30 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#31 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#32 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#33 /etc/shlink/vendor/shlinkio/shlink-common/src/Middleware/CloseDbConnectionMiddleware.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#34 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\CloseDbConnectionMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#35 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#36 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#37 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#38 /etc/shlink/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#39 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#40 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(42): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#41 /etc/shlink/module/Rest/src/Middleware/CrossDomainMiddleware.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#42 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware->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/laminas/laminas-stratigility/src/Middleware/ErrorHandler.php(129): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#45 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Laminas\Stratigility\Middleware\ErrorHandler->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/RequestIdMiddleware.php(33): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#48 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\RequestIdMiddleware->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/shlinkio/shlink-common/src/Middleware/ContentLengthMiddleware.php(16): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#51 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\ContentLengthMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#52 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#53 /etc/shlink/vendor/shlinkio/shlink-common/src/Middleware/AccessLogMiddleware.php(26): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#54 /etc/shlink/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#55 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Mezzio\Middleware\LazyLoadingMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#56 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#57 /etc/shlink/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#58 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#59 /etc/shlink/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(64): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\EmptyPipelineHandler))
#60 /etc/shlink/vendor/mezzio/mezzio/src/Application.php(34): Laminas\Stratigility\MiddlewarePipe->handle(Object(Laminas\Diactoros\ServerRequest))
#61 /etc/shlink/bin/roadrunner-worker.php(24): Mezzio\Application->handle(Object(Laminas\Diactoros\ServerRequest))
#62 /etc/shlink/bin/roadrunner-worker.php(32): {closure}()
#63 {main}
2024-03-15T11:57:32+0000        INFO    server          [2024-03-15T11:57:32.228043+00:00] [311116c4-6864-4715-a255-4c0722073040] Access.INFO - GET /dOw7X 500 28

This issue did not occur in previous versions, such as 3.7.4.

Expected behavior

When opening short url, I would like to receive a 302 response status, with location: viber://pa?chatURI=****
This behavior was in versions 3.7.4 and below

Minimum steps to reproduce

  • Create short url for viber://pa?chatURI=****
  • Open created short url
@acelaya
Copy link
Member

acelaya commented Mar 15, 2024

Thanks!

Shlink used to have two very similar dependencies used to manipulate URIs, and I removed one of them as I could not remember the reason I was using a different one in one particular place. I guess this was the reason and there was a missing test to cover this case.

@acelaya acelaya added this to the 4.0.3 milestone Mar 15, 2024
@acelaya
Copy link
Member

acelaya commented Mar 15, 2024

This is the change that caused this https://github.com/shlinkio/shlink/pull/1991/files#diff-abf169189b40a92b43093bda1780b27f63581b5fc9c4644fca78c5913773acd8

@acelaya acelaya moved this to In review in Shlink Mar 15, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Shlink Mar 15, 2024
@acelaya
Copy link
Member

acelaya commented Mar 15, 2024

I have just released Shlink 4.0.3, which fixes this issue.

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