Skip to content

Commit 59a4221

Browse files
committed
fix: Update spec_version checks
Signed-off-by: Daniel Azuma <dazuma@gmail.com>
1 parent ebee42f commit 59a4221

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/cloud_events/kafka_binding.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def encode_event(event, structured_format: false, key_mapper: :NOT_SET, **format
209209
if event.is_a?(Event::Opaque)
210210
return encode_opaque_event(event)
211211
end
212-
unless event.spec_version.start_with?("1")
212+
unless event.respond_to?(:spec_version) && event.spec_version.start_with?("1.")
213213
raise(SpecVersionError, "Unrecognized specversion: #{event.spec_version}")
214214
end
215215
if structured_format
@@ -286,7 +286,7 @@ def decode_structured_content(message, content_type, allow_opaque, **format_args
286286
**format_args)
287287
if result
288288
event = result[:event]
289-
if event && !event.spec_version.start_with?("1")
289+
if event && !(event.respond_to?(:spec_version) && event.spec_version.start_with?("1."))
290290
raise(SpecVersionError, "Unrecognized specversion: #{event.spec_version}")
291291
end
292292
return event

0 commit comments

Comments
 (0)