---
# System prepended metadata

title: Analise inicial dos erros do SmartSite encontrados no NewRelic 24/10/22

---

# Analise inicial dos erros do SmartSite encontrados no NewRelic 24/10/22

![](https://i.imgur.com/gsWpW5d.png)
Link: https://one.newrelic.com/nr1-core/errors/overview/Mjk4MTMyNHxBUE18QVBQTElDQVRJT058MTA1Mzc5OTUxNw?account=2981324&duration=259200000&state=72815f25-7ee4-a1e6-0a58-adc75113cb64

## LandingPageController#show ActionController::InvalidCrossOriginRequest

Stacktrace:
```ruby=
ActionController::InvalidCrossOriginRequest: Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.
<truncated 102 additional frames>
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'

Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, 
```
***Material de apoio***: https://die-antwort.eu/techblog/2018-08-avoid-invalid-cross-origin-request-with-catch-all-route/

Sugestão como do material de apoio forçar content_type do retorno de erros padrão, como:

![](https://i.imgur.com/8wXaM5O.png)

---

## Erro: NoMethodError: undefined method `split' for nil:NilClass

Stacktrace:
```ruby=
/workspace/app/helpers/fit_friend/vouchers_helper.rb:    3:in `fitfriend_get_name'
/workspace/app/views/v2/fit_friend/vouchers/create.html.erb:7:in `block in _app_views_v__fit_friend_vouchers_create_html_erb___3889604545526969655_134303600'
/workspace/app/views/v2/fit_friend/vouchers/create.html.erb:4:in `_app_views_v__fit_friend_vouchers_create_html_erb___3889604545526969655_134303600'
<truncated 145 additional frames>
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
```

**Erro na linha:** `/workspace/app/helpers/fit_friend/vouchers_helper.rb:3`

### Conclusão:
Acontece quando parâmetro name recebido pela função é nil

### Sugestão:
Adicionar safe navigation &:

```ruby=
  def fitfriend_get_name(name)
    name&.split&.first
  end
```

A validar!

---

## Erro: NoMethodError: undefined method `[]' for nil:NilClass

```ruby=
/workspace/app/services/eec_metrics_service.rb:  130:in `data_purchase_impression'
  /workspace/app/helpers/eec_metrics_purchase_helper.rb:   75:in `checkout_purchase'
/workspace/app/views/v2/checkout/resume.html.erb:91:in `_app_views_v__checkout_resume_html_erb___4060195125008098265_52877840'
<truncated 140 additional frames>
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
```

**Erro na linha:** `/workspace/app/services/eec_metrics_service.rb:130`

### Conclusão: 
O errro acontece por não ter os dados de email e telefone da pessoa para logar

### Sugestão: 
Remover dados de person do log

A validar!

---

## Erro: NoMethodError: undefined method `city' for nil:NilClass

```ruby=
…rkspace/app/controllers/contact_requests_controller.rb:   28:in `create'
<truncated 103 additional frames>
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
```

**Erro na linha:** `app/controllers/contact_requests_controller.rb:28`

### Conclusão:
Provavelmente esse find_by esta retornando vazio e dando erro

### Sugestão:
Verificar banco de dados, provavelmente algum @contact_request.location_id está em branco " ", ajustar dados em branco!

A validar!

