rails_twirp 0.16 → 0.17
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 +4 -4
- data/.github/workflows/test.yml +9 -3
- data/CHANGELOG.md +4 -2
- data/Gemfile +0 -1
- data/Rakefile +21 -2
- data/lib/rails_twirp/exception_handling.rb +12 -2
- data/lib/rails_twirp/version.rb +1 -1
- data/rails_twirp.gemspec +4 -5
- data/test/dummy/config/environments/test.rb +6 -2
- data/test/ping_controller_test.rb +6 -8
- metadata +18 -11
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4214210eff742236d7214ff558426f2dc9aed2e929b8e4ccb3c30777f5075bae
|
4
|
+
data.tar.gz: 8de1099ab7e26c27ce4c226325f7f0d535e5fe017e2fa4728e336b5293f767cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a148e4b8363ac7eb45423eef57e98fd3d29cb10cca70ed43c178a453a1e0d6f47b17f22f061656195aa645f8afaeeaf0b58f5dcc3e637410ecb5789137d85f3d
|
7
|
+
data.tar.gz: 959f3beeac15882ad998b88733eb1f1a4f54a4d198c5293fabfe9d8c5acd583e84d9e0d32b02ef3b1d4dc9c0909b1eba537db5e62df98ec98651f9eec9ce9c0a
|
data/.github/workflows/test.yml
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
name: Ruby Test
|
2
|
-
on: push
|
2
|
+
on: [push]
|
3
3
|
|
4
4
|
jobs:
|
5
5
|
test:
|
6
|
+
name: Ruby Tests
|
6
7
|
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: ["3.0", "3.1", "3.2", "3.3"]
|
12
|
+
|
7
13
|
steps:
|
8
|
-
- name: Checkout
|
14
|
+
- name: Checkout
|
9
15
|
uses: actions/checkout@v3
|
10
16
|
|
11
17
|
- name: Setup Ruby
|
12
18
|
uses: ruby/setup-ruby@v1
|
13
19
|
with:
|
14
|
-
ruby-version: 3.3.0
|
15
20
|
bundler-cache: true
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
16
22
|
|
17
23
|
- name: Run tests
|
18
24
|
run: bin/test
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
### 0.
|
1
|
+
### 0.17
|
2
|
+
* Adding support for rails 7.2. Mostly this was fixing the deprecation of `request.show_exceptions?` and support the various
|
3
|
+
values of `Rails.application.config.action_dispatch.show_exceptions`.
|
2
4
|
|
5
|
+
### 0.16
|
3
6
|
* Ensure `decode_rack_response` always calls `#close` on the Rack body in tests, as some middleware might be applying a BodyProxy
|
4
7
|
|
5
8
|
### 0.15
|
6
|
-
|
7
9
|
* Exclude versions of Rails 7 which were incompatible with the pbbuilder ActionView handler, as pbbuilder cannot work there at all
|
8
10
|
* Fix decode_rack_response to be compatible with Rack response body wrappers (and conform to the Rack SPEC)
|
9
11
|
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -6,8 +6,27 @@ require "rake/testtask"
|
|
6
6
|
|
7
7
|
Rake::TestTask.new(:test) do |t|
|
8
8
|
t.libs << "test"
|
9
|
-
t.
|
10
|
-
|
9
|
+
t.libs << "lib"
|
10
|
+
|
11
|
+
# Running specific tests with line numbers, like with rails test, is not supported by default in rake.
|
12
|
+
# By setting the TESTOPS env var we can however specify the name of a single test with underscores instead of spaces.
|
13
|
+
# So run your single test by calling for ex:
|
14
|
+
#
|
15
|
+
# rake test /Users/sebastian/projects/cheddar/rails-twirp/test/ping_controller_test.rb "uncaught errors should bubble up to the test"
|
16
|
+
|
17
|
+
file_name = ARGV[1]
|
18
|
+
test_name = ARGV[2]&.tr(" ", "_")
|
19
|
+
|
20
|
+
ENV["TESTOPTS"] = "--verbose"
|
21
|
+
|
22
|
+
t.test_files = if file_name
|
23
|
+
if test_name
|
24
|
+
ENV["TESTOPTS"] += " --name=test_#{test_name}"
|
25
|
+
end
|
26
|
+
[file_name]
|
27
|
+
else
|
28
|
+
FileList["test/**/*_test.rb"]
|
29
|
+
end
|
11
30
|
end
|
12
31
|
|
13
32
|
task default: :test
|
@@ -18,9 +18,19 @@ module RailsTwirp
|
|
18
18
|
|
19
19
|
# We adopt the same error handling logic as Rails' standard middlewares:
|
20
20
|
# 1. When we 'show exceptions' we make the exception bubble up—this is useful for testing
|
21
|
-
# If the exception gets raised here error reporting will happen in the middleware of the APM package
|
21
|
+
# If the exception gets raised here, error reporting will happen in the middleware of the APM package
|
22
22
|
# higher in the call stack.
|
23
|
-
|
23
|
+
#
|
24
|
+
|
25
|
+
# A backtrace cleaner acts like a filter that only shows us the backtrace
|
26
|
+
# with a selection of useful lines compared to all lines the code goes through.
|
27
|
+
backtrace_cleaner = http_request.get_header("action_dispatch.backtrace_cleaner")
|
28
|
+
|
29
|
+
# Contains various exception related methods we can use and takes the backtrace_cleaner into consideration.
|
30
|
+
exception_wrapper = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, e)
|
31
|
+
# ExceptionWrapper.show? contains the logic that chooses to pass exceptions through or not based on the
|
32
|
+
# `Rails.application.config.action_dispatch.show_exceptions` setting of :none, :rescuable and :all
|
33
|
+
raise e unless exception_wrapper.show?(http_request)
|
24
34
|
|
25
35
|
# 2. We report the error to the error tracking service, this needs to be configured.
|
26
36
|
RailsTwirp.unhandled_exception_handler&.call(e)
|
data/lib/rails_twirp/version.rb
CHANGED
data/rails_twirp.gemspec
CHANGED
@@ -13,10 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.files = `git ls-files`.split("\n")
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
spec.add_runtime_dependency "twirp", ">= 1.9", "< 1.11"
|
16
|
+
spec.add_runtime_dependency "rails", ">= 6.1.3", "!= 7.1"
|
17
|
+
spec.add_runtime_dependency "twirp", ">= 1.9"
|
18
|
+
spec.add_development_dependency "pry"
|
19
|
+
|
21
20
|
spec.required_ruby_version = ">= 3"
|
22
21
|
end
|
@@ -28,8 +28,12 @@ Rails.application.configure do
|
|
28
28
|
config.action_controller.perform_caching = false
|
29
29
|
config.cache_store = :null_store
|
30
30
|
|
31
|
-
#
|
32
|
-
|
31
|
+
# Set to one of the following (default is :all):
|
32
|
+
#
|
33
|
+
# :all - render error pages for all exceptions
|
34
|
+
# :rescuable - render error pages for exceptions declared by config.action_dispatch.rescue_responses
|
35
|
+
# :none - raise all exceptions
|
36
|
+
config.action_dispatch.show_exceptions = :none
|
33
37
|
|
34
38
|
# Disable request forgery protection in test environment.
|
35
39
|
config.action_controller.allow_forgery_protection = false
|
@@ -49,14 +49,16 @@ class PingControllerTest < RailsTwirp::IntegrationTest
|
|
49
49
|
end
|
50
50
|
|
51
51
|
test "uncaught errors should bubble up to the test" do
|
52
|
+
Rails.application.env_config["action_dispatch.show_exceptions"] = :none
|
53
|
+
|
52
54
|
req = RPC::DummyAPI::PingRequest.new
|
53
55
|
assert_raises StandardError, "Uncaught" do
|
54
56
|
rpc RPC::DummyAPI::DummyService, "UncaughtError", req
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
test "uncaught errors should return an internal error with details if show_exceptions is
|
59
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] =
|
60
|
+
test "uncaught errors should return an internal error with details if show_exceptions is all" do
|
61
|
+
Rails.application.env_config["action_dispatch.show_exceptions"] = :all
|
60
62
|
|
61
63
|
req = RPC::DummyAPI::PingRequest.new
|
62
64
|
rpc RPC::DummyAPI::DummyService, "UncaughtError", req
|
@@ -64,12 +66,10 @@ class PingControllerTest < RailsTwirp::IntegrationTest
|
|
64
66
|
assert_equal :internal, response.code
|
65
67
|
assert_equal "Uncaught", response.msg
|
66
68
|
assert_equal "StandardError", response.meta["cause"]
|
67
|
-
ensure
|
68
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] = false
|
69
69
|
end
|
70
70
|
|
71
71
|
test "uncaught errors should be fanned out to the exception handler proc if one is defined" do
|
72
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] =
|
72
|
+
Rails.application.env_config["action_dispatch.show_exceptions"] = :all
|
73
73
|
|
74
74
|
captured_exception = nil
|
75
75
|
RailsTwirp.unhandled_exception_handler = ->(e) { captured_exception = e }
|
@@ -83,11 +83,10 @@ class PingControllerTest < RailsTwirp::IntegrationTest
|
|
83
83
|
assert_kind_of StandardError, captured_exception
|
84
84
|
ensure
|
85
85
|
RailsTwirp.unhandled_exception_handler = nil
|
86
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] = false
|
87
86
|
end
|
88
87
|
|
89
88
|
test "uncaught errors should return an internal error without if show_exceptions is true and show_detailed_exceptions is false" do
|
90
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] =
|
89
|
+
Rails.application.env_config["action_dispatch.show_exceptions"] = :all
|
91
90
|
Rails.application.env_config["action_dispatch.show_detailed_exceptions"] = false
|
92
91
|
|
93
92
|
req = RPC::DummyAPI::PingRequest.new
|
@@ -97,7 +96,6 @@ class PingControllerTest < RailsTwirp::IntegrationTest
|
|
97
96
|
assert_equal "Internal error", response.msg
|
98
97
|
ensure
|
99
98
|
Rails.application.env_config["action_dispatch.show_detailed_exceptions"] = true
|
100
|
-
Rails.application.env_config["action_dispatch.show_exceptions"] = false
|
101
99
|
end
|
102
100
|
|
103
101
|
test "before error" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_twirp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.17'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bouke van der Bijl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 6.1.3
|
20
|
-
- - "
|
20
|
+
- - "!="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '7.1'
|
23
23
|
type: :runtime
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 6.1.3
|
30
|
-
- - "
|
30
|
+
- - "!="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -37,9 +37,6 @@ dependencies:
|
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.9'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '1.11'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +44,20 @@ dependencies:
|
|
47
44
|
- - ">="
|
48
45
|
- !ruby/object:Gem::Version
|
49
46
|
version: '1.9'
|
50
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
51
59
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
60
|
+
version: '0'
|
53
61
|
description:
|
54
62
|
email:
|
55
63
|
- bouke@cheddar.me
|
@@ -60,7 +68,6 @@ files:
|
|
60
68
|
- ".github/dependabot.yml"
|
61
69
|
- ".github/workflows/test.yml"
|
62
70
|
- ".gitignore"
|
63
|
-
- ".ruby-version"
|
64
71
|
- ".standard.yml"
|
65
72
|
- CHANGELOG.md
|
66
73
|
- Gemfile
|
@@ -173,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
180
|
- !ruby/object:Gem::Version
|
174
181
|
version: '0'
|
175
182
|
requirements: []
|
176
|
-
rubygems_version: 3.5.
|
183
|
+
rubygems_version: 3.5.18
|
177
184
|
signing_key:
|
178
185
|
specification_version: 4
|
179
186
|
summary: Integrate Twirp into Rails
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.3.0
|