fix(config): seed --catalog-name from default-catalog in config file#1319
fix(config): seed --catalog-name from default-catalog in config file#1319rasta-rocket wants to merge 1 commit into
Conversation
When a config file set `default-catalog` to a non-"default" name, the CLI would silently ignore it because ParseConfig was called with the flag's default value of "default" before the config was consulted. Add ParseDefaultCatalog and apply it in main before the catalog lookup, so the config file's default-catalog seeds args.CatalogName when the flag is not explicitly passed on the command line.
d0f30d8 to
f93dd0d
Compare
zeroshade
left a comment
There was a problem hiding this comment.
LGTM. Precedence is right: explicit --catalog-name wins, then the config file's default-catalog, then the built-in default; the nil-config and empty-default-catalog cases resolve correctly too. A couple of small nits inline, none blocking.
| return file | ||
| } | ||
|
|
||
| func ParseDefaultCatalog(file []byte) string { |
There was a problem hiding this comment.
nit: this unmarshals the same bytes that ParseConfig re-unmarshals on the very next line - two parses of the same config per run. Harmless for a CLI, but you could return both the *CatalogConfig and the default-catalog name from a single parse and drop this helper. Also, since it's newly exported, a one-line doc comment would be good.
|
|
||
| fileCfg := config.ParseConfig(config.LoadConfig(args.Config), args.CatalogName) | ||
| configData := config.LoadConfig(args.Config) | ||
| if !explicitFlags["catalog-name"] { |
There was a problem hiding this comment.
nit: this seeding path (seed from default-catalog when the flag is absent, explicit flag wins) is exactly what the PR fixes, but it isn't covered by a test. A small args_test.go case asserting args.CatalogName is seeded when --catalog-name is omitted (and left alone when it's explicit) would guard against regressions.
Problem
The CLI
--catalog-nameflag defaults to"default". When a config file used a different name underdefault-catalog, that value was never read ‚ParseConfigwas called with the flag's default before the config file had any chance to influence it. The result was a silent fallback to therestcatalog type with no URI, producing a confusing error:Example config that triggered the bug:
Running iceberg list would fail because my-catalog was never found in the catalog map, mergeConf was never called, and the catalog type stayed as rest.
Fix
--catalog-namewas not explicitly passed on the command line. The explicit-flag guard ensures CLI flags still take precedence.How to test
Before: Get "v1/config": unsupported protocol scheme ""
After: connects to the Glue catalog correctly.
Verify explicit flag still wins: