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

[ErrorException] Undefined array key "uid" when requiring package from artifactory #11862

Open
l3rady opened this issue Feb 23, 2024 · 2 comments
Labels

Comments

@l3rady
Copy link

l3rady commented Feb 23, 2024

My composer.json:

{
    "name": "scott/test",
    "type": "project",
    "repositories": [
        {
            "type": "composer",
            "url": "https://uat-artifactory.marex.com/artifactory/api/composer/acf-php-remote"
        },
        {
            "type": "composer",
            "url": "https://uat-artifactory.marex.com/artifactory/api/composer/packagist"
        },
        {
            "packagist": false
        }
    ],
    "config": {
        "allow-plugins": {
            "composer/installers": true
        }
    }
}

Output of composer diagnose:

Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK git version 2.34.1
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking Composer version: OK
Checking Composer and its dependencies for vulnerabilities: OK
Composer version: 2.7.1
PHP version: 8.3.1
PHP binary path: /home/scott/.phpenv/shims/php
OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
cURL version: 7.81.0 libz 1.2.11 ssl OpenSSL/3.0.2
zip: extension present, unzip present, 7-Zip not available

When I run this command:

composer require wpengine/advanced-custom-fields-pro -vvv;

I get the following output:

Running 2.7.1 (2024-02-09 15:26:28) with PHP 8.3.1 on Linux / 5.15.133.1-microsoft-standard-WSL2
Reading ./composer.json (/home/scott/Sites/test/composer.json)
Loading config file /home/scott/.config/composer/config.json
Loading config file ./composer.json (/home/scott/Sites/test/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/home/scott/Sites/test): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/home/scott/Sites/test): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/home/scott/Sites/test): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/home/scott/Sites/test): hg branch
Executing command (/home/scott/Sites/test): fossil branch list
Executing command (/home/scott/Sites/test): fossil tag list
Executing command (/home/scott/Sites/test): svn info --xml
Reading /home/scott/.config/composer/composer.json
Loading config file /home/scott/.config/composer/config.json
Loading config file /home/scott/.config/composer/composer.json (/home/scott/.config/composer/composer.json)
Reading /home/scott/Sites/test/vendor/composer/installed.json
Reading /home/scott/.config/composer/vendor/composer/installed.json
Loading plugin PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer\Plugin (from dealerdirect/phpcodesniffer-composer-installer, installed globally)
Reading /home/scott/.cache/composer/repo/https---uat-artifactory.marex.com-artifactory-api-composer-acf-php-remote/packages.json from cache
Downloading https://uat-artifactory.marex.com/artifactory/api/composer/acf-php-remote/packages.json if modified
[304] https://uat-artifactory.marex.com/artifactory/api/composer/acf-php-remote/packages.json

In ComposerRepository.php line 932:
                             
  [ErrorException]           
  Undefined array key "uid"  
                             

Exception trace:
  at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:932
 Composer\Util\ErrorHandler::handle() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:932
 Composer\Repository\ComposerRepository->whatProvides() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:503
 Composer\Repository\ComposerRepository->loadPackages() at phar:///usr/local/bin/composer/src/Composer/Repository/RepositorySet.php:198
 Composer\Repository\RepositorySet->findPackages() at phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionSelector.php:87
 Composer\Package\Version\VersionSelector->findBestCandidate() at phar:///usr/local/bin/composer/src/Composer/Command/PackageDiscoveryTrait.php:291
 Composer\Command\RequireCommand->findBestVersionAndNameForPackage() at phar:///usr/local/bin/composer/src/Composer/Command/PackageDiscoveryTrait.php:104
 Composer\Command\RequireCommand->determineRequirements() at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:213
 Composer\Command\RequireCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:384
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:145
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:93
 require() at /usr/local/bin/composer:29

And I expected this to happen:

The package wpengine/advanced-custom-fields-pro to be fetched from artifactory and installed without error.

If I point the composer repository directly to the source: https://connect.advancedcustomfields.com/packages.json composer installs the package fine. Once I put antifactory in-front of the remote repo I get the error [ErrorException] Undefined array key "uid". The packages.json that exists on artifactory is the same as https://connect.advancedcustomfields.com/packages.json. Neither contain uid fields. It would seem that when loading from artifactory, composer internally does something different and hits code that is expecting uid to be set which it isn't.

@l3rady
Copy link
Author

l3rady commented Feb 23, 2024

What is baffling to me is that I can load packagist packages through artifactory fine. If I try loading for example larapack/dd (https://packagist.org/p2/larapack/dd.json) this does not contain uids either and composer doesn't throw that error

@Seldaek
Copy link
Member

Seldaek commented Mar 1, 2024

uids are required in the composer v1 repository format which I guess artifactory implements instead of implementing the v2 format, and I am guessing they have a bug somehow? I don't know, but I don't think this is a composer issue. Composer definitely does not treat artifactory repos in any special way, they're just composer format repos.

I realize you may want to keep artifactory for other languages, but for PHP I'd definitely recommend using Private Packagist as we do ensure it is compatible and works well with Composer. Self-plug sorry but I've seen it time and time again that other vendors do not have enough php knowledge and seem to do a half job of it.

@Seldaek Seldaek added the Support label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants