lex-apollo 0.4.20 → 0.4.21
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31dc882a8d5fd761bceaba21ff853a3d3dd898df9d4377464b72b110d306af0a
|
|
4
|
+
data.tar.gz: 8dcfd2bc7c2557b298f3d503cc94b07e5a78b5a9777789f724dede41b9d0efdb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e066b3c62555b4866bfe99d6bed13a034e2b6b23f613ae7906e8eaebee90ecb2f9dd937a5e928dd8337af8945bfba9a1528deb4d3200eb82b8a92b081b6cf59
|
|
7
|
+
data.tar.gz: dd1d625f4efc30df8951ee80db9ee0cfc1c25137bae5d8571dd09265bd5eec79add3482eba3cc88d77f43b052994597577abe634080cd995eb4dc0db7601458e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.21] - 2026-04-27
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- `Apollo::Runners::Knowledge#handle_ingest` now emits warn-level logs on the three early-return failure paths (nil/blank content, nil content_type, apollo_data_not_available). Companion to PR #15: that PR added `handle_exception` to the rescue paths; this PR closes the silent-failure window for the early-return paths that fire BEFORE any rescue would. Tag values in the log line are sanitized via `gsub(/[\r\n]+/, ' ')` to prevent log-line injection from caller-controlled tags.
|
|
7
|
+
|
|
3
8
|
## [0.4.20] - 2026-04-25
|
|
4
9
|
|
|
5
10
|
### Fixed
|
|
@@ -85,9 +85,8 @@ module Legion
|
|
|
85
85
|
|
|
86
86
|
content = normalize_text_input(content)
|
|
87
87
|
log.debug("Apollo Knowledge.handle_ingest content_length=#{content.length} content_type=#{content_type} tags=#{Array(tags).size} source_agent=#{source_agent} source_channel=#{source_channel || 'nil'}") # rubocop:disable Layout/LineLength
|
|
88
|
-
|
|
89
|
-
return
|
|
90
|
-
return { success: false, error: 'apollo_data_not_available' } unless defined?(Legion::Data::Model::ApolloEntry)
|
|
88
|
+
early_error = ingest_early_return_error(content: content, content_type: content_type, tags: tags)
|
|
89
|
+
return early_error if early_error
|
|
91
90
|
|
|
92
91
|
hash = content_hash || (defined?(Helpers::Writeback) ? Helpers::Writeback.content_hash(content) : nil)
|
|
93
92
|
existing = active_duplicate_for_hash(hash)
|
|
@@ -353,6 +352,27 @@ module Legion
|
|
|
353
352
|
|
|
354
353
|
private
|
|
355
354
|
|
|
355
|
+
def ingest_early_return_error(content:, content_type:, tags:)
|
|
356
|
+
if content.strip.empty?
|
|
357
|
+
safe_tags = Array(tags).map(&:to_s).map { |t| t.gsub(/[\r\n]+/, ' ') }
|
|
358
|
+
log.warn('[apollo][handle_ingest] early-return: content is required ' \
|
|
359
|
+
"content_type=#{content_type} tags=#{safe_tags.inspect}")
|
|
360
|
+
return { success: false, error: 'content is required' }
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
if content_type.nil?
|
|
364
|
+
log.warn('[apollo][handle_ingest] early-return: content_type is required ' \
|
|
365
|
+
"content_length=#{content.to_s.length}")
|
|
366
|
+
return { success: false, error: 'content_type is required' }
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
return nil if defined?(Legion::Data::Model::ApolloEntry)
|
|
370
|
+
|
|
371
|
+
log.warn('[apollo][handle_ingest] early-return: apollo_data_not_available ' \
|
|
372
|
+
"content_type=#{content_type}")
|
|
373
|
+
{ success: false, error: 'apollo_data_not_available' }
|
|
374
|
+
end
|
|
375
|
+
|
|
356
376
|
def normalize_content_type(raw)
|
|
357
377
|
sym = raw.to_s.delete_prefix(':').gsub(%r{[/\s]}, '_').strip.downcase.to_sym
|
|
358
378
|
sym = CONTENT_TYPE_ALIASES.fetch(sym, sym)
|
|
@@ -337,6 +337,36 @@ RSpec.describe Legion::Extensions::Apollo::Runners::Knowledge do
|
|
|
337
337
|
)
|
|
338
338
|
end
|
|
339
339
|
end
|
|
340
|
+
|
|
341
|
+
context 'early-return warn logs' do
|
|
342
|
+
let(:logger) { instance_double('Logger', debug: nil, info: nil, warn: nil) }
|
|
343
|
+
|
|
344
|
+
before { allow(host).to receive(:log).and_return(logger) }
|
|
345
|
+
|
|
346
|
+
it 'emits a warn log when content is nil' do
|
|
347
|
+
host.handle_ingest(content: nil, content_type: 'fact')
|
|
348
|
+
expect(logger).to have_received(:warn).with(/early-return: content is required/)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
it 'emits a warn log when content_type is nil' do
|
|
352
|
+
host.handle_ingest(content: 'something', content_type: nil)
|
|
353
|
+
expect(logger).to have_received(:warn).with(/early-return: content_type is required/)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
it 'emits a warn log when apollo_data_not_available' do
|
|
357
|
+
hide_const('Legion::Data::Model::ApolloEntry') if defined?(Legion::Data::Model::ApolloEntry)
|
|
358
|
+
host.handle_ingest(content: 'something', content_type: 'fact')
|
|
359
|
+
expect(logger).to have_received(:warn).with(/early-return: apollo_data_not_available/)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
it 'sanitizes newline-bearing tags in the warn log' do
|
|
363
|
+
host.handle_ingest(content: nil, content_type: 'fact', tags: ["evil\nFAKE LOG LINE", 'normal'])
|
|
364
|
+
expect(logger).to have_received(:warn) do |msg|
|
|
365
|
+
expect(msg).to include('evil FAKE LOG LINE')
|
|
366
|
+
expect(msg).not_to include("\n")
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
end
|
|
340
370
|
end
|
|
341
371
|
|
|
342
372
|
describe '#handle_query' do
|