Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() }()

Expand Down
4 changes: 2 additions & 2 deletions config/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading