# Composer HTTP Authentication: unhashable type: 'dict'

**URL:** https://discourse.roots.io/t/composer-http-authentication-unhashable-type-dict/25472
**Category:** trellis
**Tags:** deploys, ansible, trellis, sage10
**Created:** 2023-06-01T18:10:31Z
**Posts:** 10

## Post 1 by @drbroad — 2023-06-01T18:10:31Z

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!

---

## Post 2 by @strarsis — 2023-06-01T18:13:54Z

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

e class='quote' data-post="1" data-topic="25436"\> 
 ![](https://discourse.roots.io/user_avatar/discourse.roots.io/strarsis/48/4543_2.png)
[Using the ACF Pro official install method with Bedrock/Trellis](https://discourse.roots.io/t/guide-using-the-acf-pro-official-install-method-with-bedrock-trellis/25436#acf-pro-site-specific-licenses-4) [bedrock](/c/bedrock/7)

> Bedrock For development, use an auth.json file in the Bedrock project folder – but it should not be committed to the repository, but rather added to .gitignore as it is a secret (the ACF PRO license), similar to the .env file. { "http-basic": { + "connect.advancedcustomfields.com": { + "username": "[ACF PRO license key]", + "password": "https://[domain.tld]" + } } } Use the ACF PRO license key as the username. The password should be the site host (…

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

---

## Post 3 by @drbroad — 2023-06-01T20:12:19Z

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.

---

## Post 4 by @drbroad — 2023-06-01T21:36:15Z

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?

---

## Post 5 by @strarsis — 2023-06-01T21:42:11Z

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?

---

## Post 6 by @strarsis — 2023-06-01T21:57:22Z

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.

---

## Post 7 by @drbroad — 2023-06-02T01:39:03Z

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.

---

## Post 8 by @strarsis — 2023-06-02T01:46:03Z

> [@drbroad](#):
>
> check to the trellis cli

:thinking: Trellis CLI [has a `check` command](https://github.com/roots/trellis-cli#:~:text=for%20remote%20environments-,check,-Checks%20if%20Trellis), did it not check the ansible version?

---

## Post 9 by @drbroad — 2023-06-02T02:02:13Z

This is what i saw when using Ansible@2.9.6:

 ![Screen Shot 2023-06-01 at 9.54.52 PM](https://discourse.roots.io/uploads/default/original/2X/4/49b608cefac47a06be709f9916241c992a167833.png)

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

---

## Post 10 by @strarsis — 2023-06-02T03:32:48Z

Then this should be added to the Trellis CLI check!

This Trellis CLI issue appears to be similar:

> <https://github.com/roots/trellis-cli/issues/376>
>
> ### Terms
> 
> - [X] I have read the [guidelines for Contributing to Roots Projects]…(https://github.com/roots/.github/blob/master/CONTRIBUTING.md)
> - [X] This request is not a duplicate of an existing issue
> - [X] This is not a personal support request that should be posted on the [Roots Discourse](https://discourse.roots.io/) community
> 
> ### Summary
> 
> Extend the dependency checks the `trellis check` command carries out to include required provisioning/deployment checks like SSH agent, keys, Ansible.
> 
> ### Motivation
> 
> #### Why are we doing this?
> Right now, `trellis check` looks for Python, Vagrant and Virtualbox compatibility related to local development, but some important checks would be:
> - system Ansible version and its compatibility
> - SSH agent being enabled
> - SSH agent keys being loaded
> 
> #### What use cases does it support?
> Would be nice to support checks of any known dependencies of the deploy/provision processes.
> 
> #### What is the expected outcome?
> An output like:
> ```
> Checking Trellis requirements...
> 
> Required:
> [✓] Ansible [>= 2.9.7]: 2.10.0
> [✓] Python [>= 3.8.0]: 3.11.2
> [✓] SSH Agent [On]: Yes
> [✓] SSH Agent [Loaded]: Yes
> 
> Optional:
> 
> [✓] Vagrant [>= 2.1.0]: 2.3.4
> [✓] VirtualBox [>= 4.3.10]: 6.1.36r152435
> ...
> ```
> #### Potential conflicts / foreseeable issues
> May conflict with Ansible version in virtual environment
> 
> ### Additional Context
> 
> _No response_
