Forging API access denied

Following the documentation to setup a node using docker works just fine, until the forging point.

I’ve updated the docker-compose.override.yml following the README.md and started my containers using docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d

When I do :

GET http://localhost:7000/api/node/status => OK
GET http://localhost:7000/api/node/status/forging => KO : {“message”:“Access Denied”}

From the node itself (inside the container itself using docker exec) or from the outside.

Logs show this error :

lisk_1 | CheckIpInList: TypeError: cidrString.split is not a function

As you can see here, it comes from the ip.cidrSubnet function used in the SDK.

So basically something is passed to this function, and it’s not a string, so it fails.

Can you sort it out ?

I allow myself to ping @michielmulders since the forum is just beginning :slight_smile:

docker-compose.override.yml
version: "3"
services:
  lisk:
    environment:
      - LISK_API_PUBLIC=true
      - 'LISK_FORGING_DELEGATES=65a2...847fb|iterations=1000000&cipherText=...&version=1'
      - 'LISK_API_WHITELIST=127.0.0.1,172.17.0.1,172.17.0.3,MY_HOME_IP'
      - 'LISK_FORGING_WHITELIST=127.0.0.1,172.17.0.1,172.17.0.3,MY_HOME_IP'

@JesusTheHun I think the ' around the last 3 lines are strange I think they shouldn’t be there, not 100% sure.

It’s a way to escape the variables, so be sure there is nothing weird going on. It’s actually a good practice.

1 Like

@JesusTheHun You are definitely allowed to tag me here! :slight_smile:

What I think the problem is that you can’t use env variables inside of your YAML file.
The error is thrown by the IP validation rule we set for this field. The rule tries to split the IP address based on the dots it holds (e.g. 10.10.10.10). However, your string MY_HOME_IP doesn’t hold any . dots so the function fails here.

I did some further research (ended up with a Python solution tho), this StackOverflow thread explains you cannot use ENV vars inside your YAML file. However, the solution they used here is to write a small script that parses the env variables and writes the parsed contents to the same or new file. Sort of a parsing script: https://stackoverflow.com/questions/52412297/how-to-replace-environment-variable-value-in-yaml-file-to-be-parsed-using-python

Let me know if that’s helpful?

@JesusTheHun Can you check where you got the MY_HOME_IP from? Does the value exist in your local env, you can try this by echo'ing it?

Also, I found this snippet from ElasticSearch’s docs:

output.elasticsearch:
  hosts: '${ES_HOSTS}'

They used ' single quotes but also added the interpolation brackets ${MY_HOME_IP}.
Have you tried this?

Thanks for your reply @michielmulders
You can totally use ENV vars inside your docker compose yaml files, but it’s not done like that as you mentioned in your latest post. I’ve done it in other projects and it works just fine.

But in this case MY_HOME_IP was just a placeholder to not publicly reveal my home IP, I hardcoded the value in the real case.

Ok, thanks for your reply!
In case you would find a solution, let us know how you did it :slight_smile:

For posterity, the issue is in the SDK 2.3.7 and is fixed in SDK 3.x .
So dear future reader if you use the config above it’ll just work fine