File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -38,18 +38,14 @@ def validate_arguments(arguments)
3838
3939 def validate_schema!
4040 schema = to_h
41- begin
42- schema_reader = JSON ::Schema ::Reader . new (
43- accept_uri : false ,
44- accept_file : -> ( path ) { path . to_s . start_with? ( Gem . loaded_specs [ "json-schema" ] . full_gem_path ) } ,
45- )
46- metaschema = JSON ::Validator . validator_for_name ( "draft4" ) . metaschema
47- errors = JSON ::Validator . fully_validate ( metaschema , schema , schema_reader : schema_reader )
48- if errors . any?
49- raise ArgumentError , "Invalid JSON Schema: #{ errors . join ( ", " ) } "
50- end
51- rescue StandardError => e
52- raise ArgumentError , "Invalid JSON Schema: #{ e . message } "
41+ schema_reader = JSON ::Schema ::Reader . new (
42+ accept_uri : false ,
43+ accept_file : -> ( path ) { path . to_s . start_with? ( Gem . loaded_specs [ "json-schema" ] . full_gem_path ) } ,
44+ )
45+ metaschema = JSON ::Validator . validator_for_name ( "draft4" ) . metaschema
46+ errors = JSON ::Validator . fully_validate ( metaschema , schema , schema_reader : schema_reader )
47+ if errors . any?
48+ raise ArgumentError , "Invalid JSON Schema: #{ errors . join ( ", " ) } "
5349 end
5450 end
5551 end
Original file line number Diff line number Diff line change @@ -51,6 +51,16 @@ class InputSchemaTest < ActiveSupport::TestCase
5151 schema . validate_arguments ( { foo : 123 } )
5252 end
5353 end
54+
55+ test "unexpected errors bubble up from validate_arguments" do
56+ schema = InputSchema . new ( properties : { foo : { type : "string" } } , required : [ :foo ] )
57+
58+ JSON ::Validator . stub ( :fully_validate , -> ( *) { raise "unexpected error" } ) do
59+ assert_raises ( RuntimeError ) do
60+ schema . validate_arguments ( { foo : "bar" } )
61+ end
62+ end
63+ end
5464 end
5565 end
5666end
You can’t perform that action at this time.
0 commit comments