graphql-engine
graphql-engine copied to clipboard
"error":"key \"sources\" not found"
Version Information
Server Version: hasura/graphql-engine:v2.2.0.cli-migrations-v3 CLI Version (for CLI related issue): v2.2.0
Environment
MAC 12.0.1
Ubuntu 20.04
What is the expected behaviour?
Migrate new changes in the server.
I have been following docs to automate the migration. However the container constantly throws an error:
{
"error":{
"path":"$.args.metadata",
"error":"key \"sources\" not found",
"code":"parse-failed"
},
}
I have followd the issues in #6813, but the solution doesnot work.
Keywords
What is the current behaviour?
The container gives constant error when trying to start the server.
How to reproduce the issue?
I followed the hasura documentation for the migrations.
- Create a new table from console
- Commit all the changes to the github
- Git pull from another computer.
- Try docker-compose up -d
version: '3.6'
services:
postgres:
image: postgres:13
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: password
POSTGRES_DB: database
graphql-engine:
image: hasura/graphql-engine:v2.2.0.cli-migrations-v3
ports:
- "8080:8080"
# extra_hosts:
# - "host.docker.internal:host-gateway"
depends_on:
- "postgres"
restart: always
volumes:
- ./hasura/migrations:/hasura-migrations
- ./hasura/metadata:/hasura-metadata
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://test:password@postgres:5432/database
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: postgres://test:password@postgres:5432/database
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
#HASURA_GRAPHQL_ADMIN_SECRET: ######
volumes:
db_data:
Screenshots or Screencast

Please provide any traces or logs that could help here.
{"type":"http-log","timestamp":"2022-02-16T21:59:17.351+0000","level":"error","detail":{"operation":{"user_vars":{"x-hasura-role":"admin"},"error":{"path":"$.args.metadata","error":"key "sources" not found","code":"parse-failed"},"request_id":"efd55fd4-ae2e-43a8-a847-003b9934fe8f","response_size":84,"request_mode":"error","raw_query":"{"type":"replace_metadata","version":2,"args":{"allow_inconsistent_metadata":true,"metadata":{"version":3}}}\n"},"request_id":"efd55fd4-ae2e-43a8-a847-003b9934fe8f","http_info":{"status":400,"http_version":"HTTP/1.1","url":"/v1/metadata","ip":"127.0.0.1","method":"POST","content_encoding":null}}} time="2022-02-16T21:59:18Z" level=fatal msg="error applying metadata \n{\n "path": "$.args.metadata",\n "error": "key \"sources\" not found",\n "code": "parse-failed"\n}"
What is the config version of your metadata? You should be able to see this in the version.yaml file
@BenoitRanque I'm getting the same error and my config version is 3 if that helps.
Did you manage to solve this? I'm haveing the same issues.
Typically this issue means your metadata is missing and can't be read from the directory the cli is looking in, could be a bunch of issues. Faced this once and the issue was windows filesystems are not case sensitive but linux filesystems are, and there was a difference in casing somewhere. Again, could be a bunch of stuff from wrong directory to failure mounting the volume. Any chance your metadata directory is empty?
Had the same problem but fixed it with hasura metadata export
. After running this, hasura metadata apply
would work again. This problem occurred for me on a reasonably new project after running hasura migrate apply --down 2
, changing some migrations and running hasura migrate apply
again.
Edit: I realised that I changed the name of metadata/databases/Snipbot/tables/public_placement.yaml
to metadata/databases/Snipbot/tables/public_placements.yaml
but didn't update the table reference in metadata/databases/Snipbot/tables/tables.yaml
Hope this helps someone.
Had the same problem but fixed it with
hasura metadata export
. After running this,hasura metadata apply
would work again. This problem occurred for me on a reasonably new project after runninghasura migrate apply --down 2
, changing some migrations and runninghasura migrate apply
again.Edit: I realised that I changed the name of
metadata/databases/Snipbot/tables/public_placement.yaml
tometadata/databases/Snipbot/tables/public_placements.yaml
but didn't update the table reference inmetadata/databases/Snipbot/tables/tables.yaml
Hope this helps someone.
This worked for our issue as well after upgrading from 2.0 to 2.7. Thanks!
I often have this issue if a file mentioned in tables.yaml
or functions.yaml
doesn't exist in the file system or is named differently.
Actually a more precise error message would be nice.