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: f197e46e616eb71f939175480496d17775c67985bf70d631ac8d089724c7ac7d
4
- data.tar.gz: c8f6ee951339eda218647c3bee95bfda3f32c6ee62a44abcaad8940b40214bd9
3
+ metadata.gz: 31dc882a8d5fd761bceaba21ff853a3d3dd898df9d4377464b72b110d306af0a
4
+ data.tar.gz: 8dcfd2bc7c2557b298f3d503cc94b07e5a78b5a9777789f724dede41b9d0efdb
5
5
  SHA512:
6
- metadata.gz: 5b4822965e47e806bf21b1e07e3a675fff365bdea474514278ab61efc1be2e3fc557756f2ad8ab32e63b2d1eb24286dfe25c44ceacbba723bd877d1402d7a5ab
7
- data.tar.gz: b67b970d6cf8734abd96c5de5e993e802ba924fd966307e60fd7911f7879559e3835d262ed653a269b740bbffd2574df9e156afe4e4c9dfd6a15b70afce6d658
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
- return { success: false, error: 'content is required' } if content.strip.empty?
89
- return { success: false, error: 'content_type is required' } if content_type.nil?
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)
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Apollo
6
- VERSION = '0.4.20'
6
+ VERSION = '0.4.21'
7
7
  end
8
8
  end
9
9
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-apollo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.20
4
+ version: 0.4.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity