Composer HTTP Authentication: unhashable type: 'dict'

I am using Trellis 1.21 and trying to convert to the newer way of authenticating my ACF pro license via composer.

I have my auth.json file excluded from my repo - that’s working fine for local updates.

I have my staging vault file as follows:

vault_wordpress_sites:
  mysite.com:
    composer_authentications:
      - {
          hostname: "connect.advancedcustomfields.com", 
          username: "[MY ACF KEY]", 
          password: "https://mysite.com"
        }

When I go to deploy to staging, using the verbose flag -vvvv I get the following:

TASK [deploy : Setup composer authentications (HTTP Basic)] 
 *********************************************************
fatal: [kinsta_staging]: FAILED! => {
    "msg": "An unhandled exception occurred while templating '{{ composer_authentications | rejectattr('type', 'defined') | union( composer_authentications | selectattr('type', 'defined') | selectattr('type', 'equalto', 'http-basic') ) }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Unexpected templating type error occurred on ({{ composer_authentications | rejectattr('type', 'defined') | union( composer_authentications | selectattr('type', 'defined') | selectattr('type', 'equalto', 'http-basic') ) }}): unhashable type: 'dict'"
}

Curious if anyone else has seen this error or could shed any insight as to what might be tripping it?
Cheers!

Just made a guide for this, including the correct configuration in Trellis:

In your posted configuration, there is a tab missing for the site (mysite.com), and tabs/spaces are significant in YAML.

1 Like

I appreciate the response - I actually used your guide as my reference. Still, that example was typed into here instead of copy and paste and was merely illustrative of the content. I have the correct spacing in my yaml file.

Maybe worth noting(?): Even with a clean composer file that doesn’t reference ACF anywhere, and removing the composer_authentications: block from my vault file - I get this error when trying to deploy:

TASK [deploy : Setup composer authentications (HTTP Basic)] *******************************************************
fatal: [kinsta_staging]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: set(). Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}

Shouldn’t it just pass over this if not declared?

One mistake I often committed more often than I should, while testing Trellis setups, is incorrectly assuming that the production configuration directory is used, instead of e.g. staging, maybe you are actually provisioning with the staging directory - and not with the production one?

Also put your wordpress_sites.yml through a linter (e.g. one built into VSCode).
When you use an online linter, you may want to redact some information.

Yup, triple-checked, linted etc - all fine
Installed a clean version of trellis using the CLI, just as default as it gets - same error:

TASK [deploy : Setup composer authentications (HTTP Basic)] *******************************************************
fatal: [kinsta_staging]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: set(). Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}

For anyone else who might see this - double check your ansible… Mine was 2.9.6, and after upgrading to 2.15 everything went just fine.
If anyone is listening: might want to add a check to the trellis cli when installing, similar to the way pip version check works.

:thinking: Trellis CLI has a check command, did it not check the ansible version?

This is what i saw when using Ansible@2.9.6:

Nothing there to indicate there was (or could be) a problem with the current Ansible version

1 Like

Then this should be added to the Trellis CLI check!

This Trellis CLI issue appears to be similar:

1 Like