Skip to content

refactor(config)!: use one error-returning config loader - #2294

Merged
zeroshade merged 3 commits into
apache:mainfrom
fallintoplace:refactor/config-single-loader-upstream-20261022
Oct 26, 2026
Merged

zeroshade merged 3 commits into
apache:mainfrom
fallintoplace:refactor/config-single-loader-upstream-20261022

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What

Use one error-returning config file loader.

Why

The old LoadConfig hides read errors for explicitly selected files.

Implementation

  • Make LoadConfig return ([]byte, error) and remove LoadConfigFile.
  • Update the CLI and keep EnvConfig best-effort.
  • Cover explicit, home-directory, and missing files.

Breaking change: config.LoadConfig now returns an error, and LoadConfigFile is removed.

@laskoviymishka laskoviymishka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only library callers of config.LoadConfig see a runtime change: an explicit file that can't be read, or an unset $HOME, now comes back as an error instead of nil data. The CLI and EnvConfig behave as they do on main.

Comment thread config/config.go Outdated
func LoadConfigFile(configPath string) ([]byte, error) {
// LoadConfig reads configuration data and reports path and read failures.
// An empty configPath selects ~/.iceberg-go.yaml. A missing implicit
// home-directory configuration is not an error. Use [ParseConfig] to decode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the doc also say what a missing implicit file returns, and that GOICEBERG_HOME isn't consulted? EnvConfig honors it, so a LoadConfig("") caller could expect the same.

Suggested change
// home-directory configuration is not an error. Use [ParseConfig] to decode
// home-directory configuration is not an error; LoadConfig returns nil data.
// Unlike [EnvConfig], it ignores GOICEBERG_HOME. Use [ParseConfig] to decode

Comment thread config/config.go
// An empty configPath selects ~/.iceberg-go.yaml. A missing implicit
// home-directory configuration is not an error. Use [ParseConfig] to decode
// the YAML and select a catalog.
func LoadConfig(configPath string) ([]byte, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tipped this toward the LoadConfig name over LoadConfigFile? Both shipped in v0.7.0, and keeping LoadConfigFile instead would break only LoadConfig callers and leave the CLI call untouched. Either name works for me; a line in the description on why would settle it.

Comment thread config/config.go
if err := yaml.Unmarshal(LoadConfig(dir), &cfg); err != nil {
// EnvConfig keeps its historical best-effort initialization behavior.
// Callers reading an explicit file should handle errors from LoadConfig.
data, _ := LoadConfig(dir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we pin this drop with a fromConfigFiles test? With GOICEBERG_HOME set this reads an explicit path, so it drops real read errors too, yet go test ./config/ still passes with the _ swapped for a panic(err). A directory at that path should still give the defaults, and a t.Setenv("HOME", "") case for LoadConfig("") would pin the UserHomeDir error as well.

Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
@fallintoplace
fallintoplace force-pushed the refactor/config-single-loader-upstream-20261022 branch from 2967c26 to 8327a5e Compare October 25, 2026 11:33

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoadConfig now reports read failures for explicit files and an unavailable home directory, while a missing default config stays nil, nil. The CLI was already on the error-returning path, and EnvConfig stays best-effort, which TestFromConfigFilesIgnoresReadErrors pins. I merged it with current main locally and the build, vet and config/CLI tests pass.

Nit: LoadConfigFile and the old LoadConfig signature are both released API, but releases.md has no entry under "Unreleased compatibility notes". As with #2290, it looks like the "sync release notes with main" commit dropped it. Could you add one (LoadConfig returns ([]byte, error), and LoadConfigFile callers switch to LoadConfig) in a follow-up? LGTM.

@zeroshade
zeroshade merged commit cc999d1 into apache:main Oct 26, 2026
16 checks passed
zeroshade added a commit to zeroshade/iceberg-go that referenced this pull request Oct 27, 2026
…pache#2307, apache#2310 and apache#2313

Requested in review: these merged without compatibility notes.
zeroshade added a commit to zeroshade/iceberg-go that referenced this pull request Oct 28, 2026
…g changes

Add release notes for the rename batch (apache#2308, apache#2314, apache#2315, apache#2316, apache#2317,
apache#2319, apache#2322, apache#2323) and for apache#2067, apache#2290, apache#2294, apache#2307, apache#2310 and apache#2313.
Remove stray blank lines inside the compatibility-notes list.
zeroshade added a commit that referenced this pull request Oct 28, 2026
docs(release): add compatibility notes for pre-v1 renames and breaking changes

Add release notes for the rename batch (#2308, #2314, #2315, #2316, #2317,
#2319, #2322, #2323) and for #2067, #2290, #2294, #2307, #2310 and #2313.
Remove stray blank lines inside the compatibility-notes list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants