hasura / hasura/graphql-engine
yaml parsing errors in CLI tool `metadata export`
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.32.1
CLI Version (for CLI related issue): 2.32.1
### Environment
Cloud
### What is the current behaviour?
Starting with version 2.32.1, I can no longer export metadata, I get an error parsing:
```
FATA[0000] failed to export metadata: cannot export sources from metadata: error parsing metadata
object: sources
file: databases.yaml
error: yaml: unmarshal errors:
line 1: cannot unmarshal !!map into []string
```
### What is the expected behaviour?
Metadata export should work
### How to reproduce the issue?
My databases.yaml (in my projects' `metadata/databases`)
```yaml
- name: imaginary-db
kind: postgres
configuration:
connection_info:
database_url:
from_env: PG_DB_CONNECTION_URL
isolation_level: read-committed
pool_settings:
connection_lifetime: 60
total_max_connections: 10
use_prepared_statements: false
tables: "!include imaginary-db/tables/tables.yaml"
functions: "!include imaginary-db/functions/functions.yaml"
```
Download the v2.32.1 binary:
```
$ ./cli-hasura-darwin-arm64 version && ./cli-hasura-darwin-arm64 --envfile ../.env metadata export --project hasura --log-level DEBUG
INFO hasura cli version=v2.32.1
DEBU global config file exists, verifying contents
DEBU global config is pre-set to &cli.GlobalConfig{UUID:"2c7618a3-e384-4bd2-84b6-dcef928f2edb", EnableTelemetry:true, ShowUpdateNotification:true, CLIEnvironment:"default"}
DEBU global config: uuid: 2c7618a3-e384-4bd2-84b6-dcef928f2edb
DEBU global config: enableTelemetry: true
DEBU global config: showUpdateNotification: true
DEBU global config: cliEnvironment: default
DEBU ENV vars read from: /Users/alecf/prompt-js/prompt-watch/.env
DEBU versions: cli: [v2.32.1] server: [v2.32.1-cloud.1]
DEBU compatibility check: [true] compatible CLI and Server
DEBU graphql engine endpoint: https://imaginary-dev.hasura.app
DEBU graphql engine admin_secret: ‹×›
DEBU server: uuid: 876e1d60-c29e-40c4-8151-ddb28ac2e0eb
DEBU telemetry: beamed fields.time=624.621625ms isError=true
DEBU failed to export metadata: cannot export sources from metadata: error parsing metadata
object: sources
file: databases.yaml
error: yaml: unmarshal errors:
line 1: cannot unmarshal !!map into []string kind="other error" location="file: /workdir/cli/internal/metadataobject/sources/sources.go, line: 256" ops="[command: hasura metadata export.RunE commands.MetadataExportOptions.Run commands.metadataModeDirectoryHandler.Export projectmetadata.Handler.ExportMetadata sources.SourceConfig.Export]"
FATA[0000] failed to export metadata: cannot export sources from metadata: error parsing metadata
object: sources
file: databases.yaml
error: yaml: unmarshal errors:
line 1: cannot unmarshal !!map into []string
```
But if I revert to v2.32.0, the export works:
```
./cli-hasura-darwin-arm64 version && ./cli-hasura-darwin-arm64 --envfile ../.env metad
ata export --project hasura --log-level DEBUG
INFO hasura cli version=v2.32.0
DEBU global config file exists, verifying contents
DEBU global config is pre-set to &cli.GlobalConfig{UUID:"2c7618a3-e384-4bd2-84b6-dcef928f2edb", EnableTelemetry:true, ShowUpdateNotification:true, CLIEnvironment:"default"}
DEBU global config: uuid: 2c7618a3-e384-4bd2-84b6-dcef928f2edb
DEBU global config: enableTelemetry: true
DEBU global config: showUpdateNotification: true
DEBU global config: cliEnvironment: default
DEBU ENV vars read from: /Users/alecf/prompt-js/prompt-watch/.env
DEBU versions: cli: [v2.32.0] server: [v2.32.1-cloud.1]
DEBU compatibility check: [true] compatible CLI and Server
DEBU graphql engine endpoint: https://imaginary-dev.hasura.app
DEBU graphql engine admin_secret: ‹×›
DEBU server: uuid: 876e1d60-c29e-40c4-8151-ddb28ac2e0eb
DEBU cli-ext: setting up using cli-ext embedded in cli binary
DEBU output: {"success":true,"output_file_path":"/var/folders/w_/b7kb19452pz062ssq59rytnc0000gn/T/619559982.json"} command="sdl to"
INFO Metadata exported
DEBU telemetry: beamed fields.time=621.546375ms isError=false
```
Also note that v2.33.0 and v2.33.1 both exhibit this problem, and v2.30 and v2.31 do *not* exhibit this problem. So this was introduced in v2.32.1 and has not been fixed.
### Screenshots or Screencast
see above for logs
### Please provide any traces or logs that could help here.
### Any possible solutions/workarounds you're aware of?
Sticking with v2.32.0
### Keywords
yaml, parsing, metadata, export, binary, cloud
Contributor guide
Research direction
Start at cli/internal/metadataobject/sources/sources.go around line 256 and reproduce metadata export with the provided databases.yaml on v2.32.1, comparing it with v2.32.0. Trace why the sources value is unmarshaled into []string, then verify that exporting the shown metadata succeeds on the affected versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100