Problem/Motivation

After install the 2.7 version we have the issue "HTTPS must be enabled for Composer downloads." How we see the issue appears on ComposerSettingsValidator.php in Version 2.6 it was working. The problem the $setting is now converted to int, the getConfig returns a "true" so is converted wrong and the check on setting !== 1 is not working.

Steps to reproduce

In version 2.7 the check was written like bellow

  public function validateStagePreOperation(PreOperationStageEvent $event): void {
    $dir = $this->pathLocator->getProjectRoot();

    try {
      $setting = (int) $this->inspector->getConfig('secure-http', $dir);
    }
    catch (\Exception $exception) {
      $event->addErrorFromThrowable($exception, $this->t('Unable to determine Composer secure-http setting.'));
      return;
    }
    if ($setting !== 1) {
      $event->addError([
        $this->t('HTTPS must be enabled for Composer downloads. See <a href=":url">the Composer documentation</a> for more information.', [
          ':url' => 'https://getcomposer.org/doc/06-config.md#secure-http',
        ]),
      ]);
    }
  }

In version 2.6 the check was written like bellow

  public function validateStagePreOperation(PreOperationStageEvent $event): void {
    $config = $event->getStage()
      ->getActiveComposer()
      ->getComposer()
      ->getConfig();

    if ($config->get('secure-http') !== TRUE) {
      $event->addError([
        $this->t('HTTPS must be enabled for Composer downloads. See <a href=":url">the Composer documentation</a> for more information.', [
          ':url' => 'https://getcomposer.org/doc/06-config.md#secure-http',
        ]),
      ]);
    }
  }

Proposed resolution

Change the getConfig and return correct the true / false or change the check "if ($setting !== 1) {"

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cola created an issue. See original summary.

wim leers’s picture

This is due to a change in Composer 2.5.5. See #3351594: As of Composer 2.5.5, `composer config` JSON-encodes boolean values.

For now, the best work-around is to stay on composer <=2.5.4.

cola’s picture

Hi Wim Leers, we use Composer Version: 2.5.4 2023-02-15 13:10:06

wim leers’s picture

Assigned: Unassigned » tedbow

Ah 😅 Weird that this is only reported now then, so many months after release. But not impossible.

We're actively working on the 3.x branch though, so I'm not sure if we'll fix this any time soon. Will ping @tedbow.

cola’s picture

We use right now version 2.6 which is working with this composer version!

wim leers’s picture

Hm … how sure are you that it really is version 2.5.4 that is being used? 😅 Any chance there's 2 different Composers installed? 🤓

Opened #3354914: Package Manager should have status report entry to inform user of Composer version being used to make it easier in the future to have 100% confidence about the Composer version being used.

tedbow’s picture

@cola I think the solution would be to backport #3351594: As of Composer 2.5.5, `composer config` JSON-encodes boolean values(tests and all). Right now I don't know how different ComposerInspector is but if they are not that different it might now be hard.

It seems like you should be only hitting this if you are on Composer 2.5.5 but regardless people will start to hit this on 8.x-2.x as they upgrade.

re #4

We're actively working on the 3.x branch though, so I'm not sure if we'll fix this any time soon. Will ping @tedbow.

Our scrum team is working on 3.x but @cola if you wanted to backport this we could review and commit.

Backporting at least would tell you if it fixes your problem

cola’s picture

@wim-leers youre right, drupal / symfony execute it with 2.5.5 2023-03-21 11:50:05
@tedbow would be nice if you can backport it on 2.x version

wim leers’s picture

Title: Wrong check on "HTTPS must be enabled for Composer downloads." » Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads."
Priority: Critical » Major

@cola: thanks for checking! 🙏

We need to favor project velocity right now, so if you could downgrade to Composer 2.5.4 for now, that'd be wonderful 🤞

cola’s picture

@wim-leers we cannot downgrade it, another dependency on this version :) but we will use the release 2.6 with this version is working!

wim leers’s picture

Huh! Is there something that requires Composer 2.5.5 on your system? What could that be? 🤔 Fascinating! 🤓

tedbow’s picture

@tedbow would be nice if you can backport it on 2.x version

We can review and commit any work done on this issue to backport #3351594: As of Composer 2.5.5, `composer config` JSON-encodes boolean values to 2.x.

tedbow’s picture

Assigned: tedbow » Unassigned
tedbow’s picture

Version: 8.x-2.7 » 8.x-2.x-dev
Assigned: Unassigned » yash.rode

@yash.rode, could backport the fix in #3351594: As of Composer 2.5.5, `composer config` JSON-encodes boolean values from the 3.0.x branch to the 8.x-2.x branch? I should hopefully just be bringing the changes from this commit https://git.drupalcode.org/project/automatic_updates/-/commit/1f8516c0a2...

yash.rode made their first commit to this issue’s fork.

yash.rode’s picture

Issue tags: +sprint

yash.rode’s picture

Title: Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads." » [PP-1]Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads."
Status: Active » Postponed
Related issues: +#3358878: Test failing on 8.x-2.x on 10.0.x and 10.1.x

yash.rode’s picture

Once the blocker is in MR 861 will also start passing.

tedbow’s picture

Issue tags: +contrib-only
yash.rode’s picture

Status: Postponed » Needs work

waiting for tests to pass, once it is green can be reviewed.

yash.rode’s picture

Title: [PP-1]Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads." » Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads."
Assigned: yash.rode » Unassigned
Status: Needs work » Needs review

Blocker is in!

wim leers’s picture

Assigned: Unassigned » tedbow
Status: Needs review » Reviewed & tested by the community

  • tedbow committed 90375d71 on 8.x-2.x authored by yash.rode
    Issue #3354827 by yash.rode, cola, Wim Leers: Since Composer 2.5.5: "...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed

@yash.rode, @Wim Leers thanks for getting this and the blockers fixed!

@cola if this is still an issue for you please let us know if it fixes it for you

tedbow’s picture

Assigned: tedbow » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.