Skip to content

Fatal Error in HASURA_GRAPHQL_JWT_SECRET Parsing #241

@TimaxLacs

Description

@TimaxLacs

Issue Title: HASURA_GRAPHQL_JWT_SECRET Variable Parsing Error During Deep Setup

Description:
During the setup of a Deep instance on a server, the HASURA_GRAPHQL_JWT_SECRET environmental variable causes a fatal error, preventing the Hasura container from starting up correctly. The error indicates that the JWT_SECRET variable is not recognized as valid JSON.

Steps to Reproduce:

  1. Set up a server environment (Ubuntu).

  2. Install required packages and dependencies (Docker, NVM, Node.js):

    sudo apt update
    sudo apt install -y git curl docker.io docker-compose
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
    nvm install 18 && nvm alias default 18 && nvm use default
    npm i -g npm@latest
  3. Generate the JWT_SECRET value:

    export JWT_SECRET=$(node -e "console.log(JSON.stringify({type: 'HS256', key: require('crypto').randomBytes(50).toString('base64')}))")
  4. Update the call-options.json to include the JWT_SECRET:

    {
      "operation": "run",
      "envs": {
        "DEEPLINKS_PUBLIC_URL": "http://your.deeplinks.host",
        "NEXT_PUBLIC_DEEPLINKS_URL": "http://your.deeplinks.host",
        "NEXT_PUBLIC_GQL_PATH": "your.deeplinks.host/gql",
        "NEXT_PUBLIC_GQL_SSL": "0",
        "NEXT_PUBLIC_DEEPLINKS_SERVER": "http://your.deepcase.host",
        "NEXT_PUBLIC_ENGINES_ROUTE": "0",
        "NEXT_PUBLIC_DISABLE_CONNECTOR": "1",
        "JWT_SECRET": "'{\"type\":\"HS256\",\"key\":\"<generated_key>\"}'",
        "DEEPLINKS_HASURA_STORAGE_URL": "http://host.docker.internal:8000/",
        "HASURA_GRAPHQL_ADMIN_SECRET": "<your_admin_secret>",
        "MIGRATIONS_HASURA_SECRET": "<your_admin_secret>",
        "DEEPLINKS_HASURA_SECRET": "<your_admin_secret>",
        "POSTGRES_PASSWORD": "<your_postgres_password>",
        "HASURA_GRAPHQL_DATABASE_URL": "postgres://postgres:<your_postgres_password>@postgres:5432/postgres",
        "POSTGRES_MIGRATIONS_SOURCE": "postgres://postgres:<your_postgres_password>@host.docker.internal:5432/postgres?sslmode=disable",
        "RESTORE_VOLUME_FROM_SNAPSHOT": "0",
        "MANUAL_MIGRATIONS": "1",
        "MINIO_ROOT_USER": "<your_minio_access_key>",
        "MINIO_ROOT_PASSWORD": "<your_minio_secret_key>",
        "S3_ACCESS_KEY": "<your_minio_access_key>",
        "S3_SECRET_KEY": "<your_minio_secret_key>"
      }
    }
  5. Follow the remaining steps to set up and start the Deep instance.

Expected Result:
The Deep instance should start correctly, with all containers running and able to process requests.

Actual Result:
The deep-hasura container fails to start, citing JSON formatting errors for the HASURA_GRAPHQL_JWT_SECRET variable.

Error Logs:

docker logs deep-hasura
Fatal Error:- Environment variable HASURA_GRAPHQL_JWT_SECRET: Error in $: Failed reading: not a valid json value

Environment:

  • OS: Ubuntu 20.04
  • Node.js version: 18.19.0
  • Docker version: 20.10.7
  • NVM version: v0.39.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions