Skip to content

Commit c3738e9

Browse files
committed
fix tapioca issue with types - can't use the "LogStruct" name as a value for an enum
1 parent f2d026b commit c3738e9

11 files changed

Lines changed: 56 additions & 15 deletions

File tree

lib/log_struct.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Core library files
55
require "log_struct/sorbet"
66
require "log_struct/version"
7-
require "log_struct/enums" # All enums are now in the enums directory
7+
require "log_struct/enums"
88
require "log_struct/configuration"
99
require "log_struct/formatter"
1010
require "log_struct/railtie"

lib/log_struct/concerns/error_handling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def error_handling_mode_for(source)
2121
case source
2222
when Source::TypeChecking
2323
config.error_handling_modes.type_checking_errors
24-
when Source::LogStruct
24+
when Source::Internal
2525
config.error_handling_modes.logstruct_errors
2626
when Source::Security
2727
config.error_handling_modes.security_errors

lib/log_struct/enums/source.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ class Source < T::Enum
77
enums do
88
# Error sources
99
TypeChecking = new(:type_checking) # For type checking errors (Sorbet)
10-
LogStruct = new(:logstruct) # Errors from LogStruct itself
1110
Security = new(:security) # Security-related events
11+
# Errors from LogStruct. (Cannot use LogStruct here because it confuses tapioca.)
12+
Internal = new(:logstruct)
1213

1314
# Application sources
1415
Rails = new(:rails) # For request-related logs/errors

lib/log_struct/formatter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def process_values(arg, recursion_depth: 0)
9494
T.unsafe(arg).to_s
9595
end
9696
rescue => e
97-
LogStruct.handle_exception(e, source: Source::LogStruct)
97+
LogStruct.handle_exception(e, source: Source::Internal)
9898
"[GLOBALID_ERROR]"
9999
end
100100
end
@@ -115,7 +115,7 @@ def process_values(arg, recursion_depth: 0)
115115
value_type: arg.class.name,
116116
recursion_depth: recursion_depth
117117
}
118-
LogStruct.handle_exception(e, source: Source::LogStruct, context: context)
118+
LogStruct.handle_exception(e, source: Source::Internal, context: context)
119119
arg
120120
end
121121

@@ -166,7 +166,7 @@ def log_value_to_hash(log_value, time:)
166166
object_class: log_value.class.name,
167167
object_inspect: log_value.inspect.truncate(100)
168168
}
169-
LogStruct.handle_exception(e, source: Source::LogStruct, context: context)
169+
LogStruct.handle_exception(e, source: Source::Internal, context: context)
170170

171171
# Fall back to the string representation to ensure we continue processing
172172
log_value.to_s

lib/log_struct/integrations/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.subscribe_to_sql_notifications
5858
::ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
5959
handle_sql_event(name, start, finish, id, payload)
6060
rescue => error
61-
LogStruct.handle_exception(error, source: LogStruct::Source::LogStruct)
61+
LogStruct.handle_exception(error, source: LogStruct::Source::Internal)
6262
end
6363
end
6464

lib/log_struct/multi_error_reporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def fallback_logging(error, context = {})
136136

137137
# Create a proper error log entry
138138
error_log = Log::Error.from_exception(
139-
Source::LogStruct,
139+
Source::Internal,
140140
error,
141141
context
142142
)

sorbet/rbi/annotations/actionpack.rbi

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sorbet/rbi/annotations/activerecord.rbi

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sorbet/rbi/annotations/activesupport.rbi

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/log_struct/integrations/active_record_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class ActiveRecordTest < ActiveSupport::TestCase
391391
first_exception = T.let(exceptions_logged.first, T.nilable(T::Array[T.untyped]))
392392

393393
assert_not_nil first_exception
394-
assert_equal LogStruct::Source::LogStruct, T.must(first_exception)[1]
394+
assert_equal LogStruct::Source::Internal, T.must(first_exception)[1]
395395
end
396396

397397
test "integration is included in automatic setup" do

0 commit comments

Comments
 (0)