Requiring sdk package with Slim framework breaks PSR7 detection
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- observability
Research direction
The failing lookup is the try block in Trace/AutoRootSpan.php around line 73, which builds the server request via the Nyholm factory; the stack trace shows Slim's NyholmPsr17Factory being hit through ServerRequestCreatorFactory. Start by reading that block and the nyholm/psr7-server entry in composer.json. Done means the server request is created without hard-coding a Nyholm class, and the Slim app from the report runs with only guzzlehttp/psr7 installed.
Written by the indexing model from the issue text.
Description
Describe your environment
open-telemetry/sdk version: 1.15.0
slim/slim version: 4.11.0
guzzlehttp/psr7 version: 2.13.1
php version: 8.4
Steps to reproduce
-
Require the above listed packages. DO NOT require
nyholm/psr7. Since we're requiring Guzzle's PSR7 implementation, that should meet the psr7 requirement for all the packages.composer require slim/slim:4.11.0 open-telemetry/sdk:1.15.0 guzzlehttp/psr7:2.13.1 -
Write a simple Slim app like the following to a file named
index.php:<?php require_once __DIR__.'/vendor/autoload.php'; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Slim\Factory\AppFactory; $app = AppFactory::create(); $app->get('/', function(ServerRequestInterface $request, ResponseInterface $response) { $response->getBody()->write('hello world'); return $response; }); $app->run();
Attempt to run it:
php index.php
What is the expected behavior?
I expect to see hello world printed.
What is the actual behavior?
An exception is thrown:
Fatal error: Uncaught Error: Class "Nyholm\Psr7\Factory\Psr17Factory" not found in /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/vendor/slim/slim/Slim/Factory/Psr17/NyholmPsr17Factory.php on line 25
Error: Class "Nyholm\Psr7\Factory\Psr17Factory" not found in /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/vendor/slim/slim/Slim/Factory/Psr17/NyholmPsr17Factory.php on line 25
Call Stack:
0.0005 420416 1. {main}() /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/src/index.php:0
0.0312 1421264 2. Slim\App->run($request = ???) /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/src/index.php:14
0.0314 1427912 3. Slim\Factory\ServerRequestCreatorFactory::create() /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/vendor/slim/slim/Slim/App.php:179
0.0314 1427912 4. Slim\Factory\ServerRequestCreatorFactory::determineServerRequestCreator() /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/vendor/slim/slim/Slim/Factory/ServerRequestCreatorFactory.php:30
0.0320 1473192 5. Slim\Factory\Psr17\NyholmPsr17Factory::getServerRequestCreator() /private/var/folders/kd/r97q1j9567qc1tv181jnnfm80000gp/T/tmp.fqmTOhOo4I/vendor/slim/slim/Slim/Factory/ServerRequestCreatorFactory.php:47
Additional context
This issue arises because the open-telemetry/sdk package requires the nyholm/psr7-server package specifically which only provides a tiny subset of the full nyholm/psr7 package and seems to be abandoned. It is used in a single spot. I'm not certain it should be there since the php-http/discovery package is also a requirement. I think that try block could be reduced to:
$factory = new Psr17Factory();
return $factory->createServerRequestFromGlobals();
That would rely on whatever Psr17Factory the user chooses instead of tying this library to a single implementation.
- Dominant language
- PHP
- Stars
- 923
- Forks
- 234
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 35
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from open-telemetry/opentelemetry-php
-
[opentelemetry-php-contrib] laravel: queue hooks fail with sem-conv 1.45 (undefined MessagingIncubatingAttributes::MESSAGING_SYSTEM)Possibly taken @gowtham-padala claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
open-telemetry/opentelemetry-php#2139 ·
Maintainers usually reply within 1 day
-
Invalid numeric `OTEL_*` values abort initialization instead of falling backPossibly taken @gowtham-padala claimed this 1 day ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-php#2136 ·
Maintainers usually reply within 1 day
-
bite sized help wanted
Difficulty 1/5 Under an hour Newbie friendliness 68/100
open-telemetry/opentelemetry-php#1902 · 1 comment · 3 reactions ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
open-telemetry/opentelemetry-php#2143 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
open-telemetry/opentelemetry-php#2137 ·
Maintainers usually reply within 1 day
All issues in open-telemetry/opentelemetry-php
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Icinga/icinga-notifications-web#653 ·
Maintainers usually reply within 1 day
-
MCP Bundle
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
15.0
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vimeo/psalm#14139 · 1 comment ·
Maintainers usually reply within 2 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day