Commit 75ba22b
authored
fix: Account for
* fix: Account for `nil` routes
It seems that there are cases in Rails functional tests where it bypasses the routing system and the `action_dispatch.route_uri_pattern` header not being set.
https://github.com/rails/rails/blob/747f85f200e7bb2c1a31b4e26e5a5655e2dc0cdc/actionpack/lib/action_dispatch/http/request.rb#L160
```console
4) SessionsController POST #create when user is not found or not persisted redirects to no access path
Failure/Error: post :create, params: { provider: 'github' }
NoMethodError:
undefined method 'chomp' for nil
# /usr/local/bundle/gems/opentelemetry-instrumentation-action_pack-0.12.0/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb:56:in 'OpenTelemetry::Instrumentation::ActionPack::Handlers::ActionController#to_span_name_and_attributes'
# /usr/local/bundle/gems/opentelemetry-instrumentation-action_pack-0.12.0/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb:26:in 'OpenTelemetry::Instrumentation::ActionPack::Handlers::ActionController#start'
# ./spec/controllers/sessions_controller_spec.rb:28:in 'block (4 levels) in <top (required)>'
```
Our Test suite executes the routing system so we are unable to recreate this error case.
This change adds safe navigation navigation to avoid running into errors when running Functional Tests and the instrumentation is enabled.
```console
irb(main):003> route_uri_pattern.chomp('(.format)')
(irb):3:in '<main>': undefined method 'chomp' for nil (NoMethodError)
from <internal:kernel>:168:in 'Kernel#loop'
from /Users/arielvalentin/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
from /Users/arielvalentin/.rbenv/versions/3.4.1/bin/irb:25:in 'Kernel#load'
from /Users/arielvalentin/.rbenv/versions/3.4.1/bin/irb:25:in '<main>'
irb(main):004> route_uri_pattern&.chomp('(.format)')
=> nil
```
* squash: Add comments
To explain the lack of test coveragenil routes (#1527)1 parent eae73d6 commit 75ba22b
File tree
1 file changed
+4
-1
lines changed- instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers
1 file changed
+4
-1
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
0 commit comments