legion-settings 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/docs/plans/2026-03-17-config-error-filename-design.md +56 -0
- data/docs/plans/2026-03-17-config-error-filename-implementation.md +34 -0
- data/lib/legion/settings/loader.rb +21 -3
- data/lib/legion/settings/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f66aca7decaa9e60f84abf3d4b2538f42a90978289916f535395991161bb8e24
|
|
4
|
+
data.tar.gz: 41c5f1bac7ec1e12d0034ad872816405588d880542efbe7c420ec958697f1991
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 967b78c6ca4e9e2bee7a2ac1e53c6198a0b0606985e16fca8734c061be6b5b5b4f30e7ed882c387af00554f3323e9008269e036eaec09e9b7ee12d1e1c8ad349
|
|
7
|
+
data.tar.gz: 2451834575d97a57f1f11c41556f48cf581358624c793d8ac011158b174df2072988d1135af0b9fc3656d1fd608734ab155a2f5b7419d71f77a613e5d8677994
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Legion::Settings Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.4] - 2026-03-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Added `logger` gem to test dependencies for Ruby 4.0 compatibility
|
|
7
|
+
|
|
8
|
+
## [1.3.3] - 2026-03-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Config JSON parse error now includes the filename at ERROR level instead of burying it in DEBUG
|
|
12
|
+
|
|
3
13
|
## [1.3.2] - 2026-03-17
|
|
4
14
|
|
|
5
15
|
### Added
|
data/Gemfile
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Design: Include Filename in JSON Parse Error Messages
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
When a user edits a config file and introduces a JSON syntax error, the settings loader logs:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
ERROR config file must be valid json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The filename is only logged at DEBUG level on the next line:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
Legion::Logging.error('config file must be valid json')
|
|
15
|
+
Legion::Logging.debug("file:#{file}, error: #{e}")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This makes it nearly impossible for users to identify which file is broken, especially when multiple config files exist in `~/.legionio/settings/`. The settings loader silently skips the broken file, and downstream code fails with confusing errors (e.g., RubyLLM complaining about missing API keys because `llm.json` wasn't loaded).
|
|
19
|
+
|
|
20
|
+
## Proposed Solution
|
|
21
|
+
|
|
22
|
+
Change `load_file` in `loader.rb` to include the filename and parse error in the ERROR message:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
rescue Legion::JSON::ParseError => e
|
|
26
|
+
Legion::Logging.error("config file must be valid json: #{file}")
|
|
27
|
+
Legion::Logging.error(" parse error: #{e.message}")
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This is a one-line change (plus one added line) in `loader.rb:140-142`.
|
|
32
|
+
|
|
33
|
+
### Before
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
[2026-03-17 18:27:27 -0500] ERROR config file must be valid json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### After
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
[2026-03-17 18:27:27 -0500] ERROR config file must be valid json: /Users/matt/.legionio/settings/llm.json
|
|
43
|
+
[2026-03-17 18:27:27 -0500] ERROR parse error: unexpected token at '{ "llm": { ... '
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Alternatives Considered
|
|
47
|
+
|
|
48
|
+
1. **Raise instead of logging** — rejected; the current behavior of skipping broken files and continuing is correct for resilience. But the user needs to know what happened.
|
|
49
|
+
2. **Add a `config validate` pre-check** — already exists (`legion config validate`), but users won't run it proactively. The error message at load time is the first line of defense.
|
|
50
|
+
3. **Return the broken files in `loaded_files`** — would require API changes for minimal benefit.
|
|
51
|
+
|
|
52
|
+
## Constraints
|
|
53
|
+
|
|
54
|
+
- Do not change the error-handling behavior (continue loading other files)
|
|
55
|
+
- Do not change method signatures
|
|
56
|
+
- The debug line can be removed since the info is now in the error message
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Implementation: Include Filename in JSON Parse Error Messages
|
|
2
|
+
|
|
3
|
+
## Phase 1: Update Error Logging
|
|
4
|
+
|
|
5
|
+
### Files to Modify
|
|
6
|
+
|
|
7
|
+
- `lib/legion/settings/loader.rb` — lines 140-142
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
|
|
11
|
+
Replace:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
rescue Legion::JSON::ParseError => e
|
|
15
|
+
Legion::Logging.error('config file must be valid json')
|
|
16
|
+
Legion::Logging.debug("file:#{file}, error: #{e}")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
rescue Legion::JSON::ParseError => e
|
|
23
|
+
Legion::Logging.error("config file must be valid json: #{file}")
|
|
24
|
+
Legion::Logging.error(" parse error: #{e.message}")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Spec Coverage
|
|
28
|
+
|
|
29
|
+
- Add spec in `spec/legion/loader_spec.rb` that writes invalid JSON to a temp file, calls `load_file`, and asserts the error was logged with the filename
|
|
30
|
+
|
|
31
|
+
### Version Bump
|
|
32
|
+
|
|
33
|
+
- Bump patch version in `lib/legion/settings/version.rb`
|
|
34
|
+
- Update CHANGELOG.md
|
|
@@ -38,7 +38,25 @@ module Legion
|
|
|
38
38
|
vault: { connected: false }
|
|
39
39
|
},
|
|
40
40
|
cache: { enabled: true, connected: false, driver: 'dalli' },
|
|
41
|
-
extensions: {
|
|
41
|
+
extensions: {
|
|
42
|
+
core: %w[
|
|
43
|
+
lex-node lex-tasker lex-scheduler lex-health lex-ping
|
|
44
|
+
lex-telemetry lex-metering lex-log lex-audit
|
|
45
|
+
lex-conditioner lex-transformer lex-exec lex-lex lex-codegen
|
|
46
|
+
],
|
|
47
|
+
ai: %w[lex-claude lex-openai lex-gemini],
|
|
48
|
+
gaia: %w[lex-tick lex-mesh lex-apollo lex-cortex],
|
|
49
|
+
categories: {
|
|
50
|
+
core: { type: :list, tier: 1 },
|
|
51
|
+
ai: { type: :list, tier: 2 },
|
|
52
|
+
gaia: { type: :list, tier: 3 },
|
|
53
|
+
agentic: { type: :prefix, tier: 4 }
|
|
54
|
+
},
|
|
55
|
+
blocked: [],
|
|
56
|
+
reserved_prefixes: %w[core ai agentic gaia],
|
|
57
|
+
reserved_words: %w[transport cache crypt data settings json logging llm rbac legion],
|
|
58
|
+
agentic: { allowed: nil, blocked: [] }
|
|
59
|
+
},
|
|
42
60
|
reload: false,
|
|
43
61
|
reloading: false,
|
|
44
62
|
auto_install_missing_lex: true,
|
|
@@ -120,8 +138,8 @@ module Legion
|
|
|
120
138
|
# @indifferent_access = false
|
|
121
139
|
@loaded_files << file
|
|
122
140
|
rescue Legion::JSON::ParseError => e
|
|
123
|
-
Legion::Logging.error(
|
|
124
|
-
Legion::Logging.
|
|
141
|
+
Legion::Logging.error("config file must be valid json: #{file}")
|
|
142
|
+
Legion::Logging.error(" parse error: #{e.message}")
|
|
125
143
|
end
|
|
126
144
|
else
|
|
127
145
|
Legion::Logging.warn("Config file does not exist or is not readable file:#{file}")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion-settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -42,6 +42,8 @@ files:
|
|
|
42
42
|
- Gemfile
|
|
43
43
|
- LICENSE
|
|
44
44
|
- README.md
|
|
45
|
+
- docs/plans/2026-03-17-config-error-filename-design.md
|
|
46
|
+
- docs/plans/2026-03-17-config-error-filename-implementation.md
|
|
45
47
|
- legion-settings.gemspec
|
|
46
48
|
- lib/legion/settings.rb
|
|
47
49
|
- lib/legion/settings/loader.rb
|