diff --git a/CHANGELOG.md b/CHANGELOG.md index 8378e53..4c824c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.12.2] - 2026-03-31 + +### Fixed + +- **config** — File I/O errors (missing or unreadable `.env`/JSON files) and JSON parse errors are now classified as `errors.Internal` instead of `errors.BadRequest`; error message updated from `"file not found"` to `"cannot open file"` to better reflect the server-side cause + ## [0.12.1] - 2026-03-30 ### Fixed diff --git a/config/config_test.go b/config/config_test.go index 0801099..ec8aa7d 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -323,8 +323,8 @@ func TestLoad_EnvFileMissing_Required(t *testing.T) { if err == nil { t.Fatal("expected error for missing required env file") } - if !strings.Contains(err.Error(), "file not found") { - t.Errorf("error = %q, want it to contain 'file not found'", err.Error()) + if !strings.Contains(err.Error(), "cannot open file") { + t.Errorf("error = %q, want it to contain 'cannot open file'", err.Error()) } } diff --git a/config/env.go b/config/env.go index 1e7279f..31a229a 100644 --- a/config/env.go +++ b/config/env.go @@ -18,7 +18,7 @@ func loadEnvFile(path string, required bool) (map[string]string, error) { if os.IsNotExist(err) && !required { return nil, nil } - return nil, errors.BadRequest("config: file not found: " + path) + return nil, errors.Internal("config: cannot open file: " + path) } defer func() { _ = f.Close() }() diff --git a/config/json.go b/config/json.go index 46fd0c0..47cafeb 100644 --- a/config/json.go +++ b/config/json.go @@ -19,12 +19,12 @@ func loadJSONFile(path string, required bool) (map[string]string, error) { if os.IsNotExist(err) && !required { return nil, nil } - return nil, errors.BadRequest("config: file not found: " + path) + return nil, errors.Internal("config: cannot open file: " + path) } var raw map[string]any if err := json.Unmarshal(data, &raw); err != nil { - return nil, errors.BadRequest(fmt.Sprintf("config: invalid JSON in %s: %v", path, err)) + return nil, errors.Internal(fmt.Sprintf("config: invalid JSON in %s: %v", path, err)) } result := make(map[string]string)