hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.07k stars 2.76k forks source link

CLI migration parsing errors should be more helpful #7856

Open corsali-albert opened 2 years ago

corsali-albert commented 2 years ago

Version Information

Server Version: v2.0.10 CLI Version (for CLI related issue): v2.0.10

Environment

Cloud and Docker

What is the expected behaviour?

Metadata apply should work

Keywords

metadata, sources, parse

What is the current behaviour?

Metadata apply fails with below error.

FATA[0000] failed to apply metadata:
{
  "path": "$.metadata",
  "error": "key \"sources\" not found",
  "code": "parse-failed"
}

How to reproduce the issue?

  1. Add a table.
  2. Rename the generated metadata/.../public_table.yml file to metadata/.../public_Table.yml.
  3. Apply metadata

Any possible solutions?

Ensure all table file names are all lower-case (or that they match the tables.yml file, not sure which is required).

If the bug is confirmed, would you be willing to submit a PR?

Not sufficiently familiar with this code base, sorry! If someone pointed me to the location where such a change could be made, I'd be happy to though.

BenoitRanque commented 2 years ago

Casing should match the tables.yaml file. The error could be clearer, but the behavior itself is expected. Do note that linux filesystems are case sensitive. Be careful when manually editing metadata files.

Curious why you would rename the files?

corsali-albert commented 2 years ago

I'm not sure why the file was named improperly (caught in a PR of someone else's code), but perhaps it was an initial table creation that was then re-cased -- would that cause a renaming of the file with the updated case?

This was more about the non-specific error, though; when googling for it, there several other "well, something is wrong with your hasura config somewhere" suggestions, none of which were helpful to debug. At the very least, hopefully this issue will be in the pool of others when that error occurs.

BenoitRanque commented 2 years ago

Agree that we should have some more helpful error messages for those cases. The error message "key \"sources\" not found" means there was an unhandled error in parsing the metadata from the metadata files.

For your specific case, I was able to track down a bug in cli/console behavior, and I opened issue #7866

That said, we should also improve error messages for those cases, so I am not closing this issue