Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect line number in backtrace #498

Open
HunterMeyer opened this issue Feb 6, 2021 · 1 comment
Open

Incorrect line number in backtrace #498

HunterMeyer opened this issue Feb 6, 2021 · 1 comment

Comments

@HunterMeyer
Copy link

HunterMeyer commented Feb 6, 2021

I'm having an issue debugging an error.
We're getting a stack trace like:

JSON::GeneratorError: source sequence is illegal/malformed utf-8
  from active_support/core_ext/object/json.rb:38:in `to_json'
  from active_support/core_ext/object/json.rb:38:in `to_json'
  from active_support/json/encoding.rb:57:in `to_json'
  from json/common.rb:223:in `generate'
  from json/common.rb:223:in `generate'
  from active_support/json/encoding.rb:102:in `stringify'
  from active_support/json/encoding.rb:35:in `encode'
  from active_support/json/encoding.rb:22:in `encode'
  from active_support/core_ext/object/json.rb:41:in `to_json'
  from jbuilder.rb:251:in `target!'
  from jbuilder/jbuilder_template.rb:81:in `target!'
  from app/views/api/v1/stream/index.json.jbuilder:13:in `_app_views_api_v__stream_index_json_jbuilder__1111274208592270428_47381428682480'
  from action_view/template.rb:159:in `block in render'
  from active_support/notifications.rb:168:in `block in instrument'
  from active_support/notifications/instrumenter.rb:23:in `instrument'
  from active_support/notifications.rb:168:in `instrument'
  from action_view/template.rb:354:in `instrument_render_template'
  from action_view/template.rb:157:in `render'

Notice the trace is reporting the exception on line 13 of our jbuilder file

app/views/api/v1/stream/index.json.jbuilder:13

However, that file only has 11 lines.

1  # frozen_string_literal: true
2
3  json.total @records.size
4
5  json.records @records do |record|
6    json.partial! 'api/v1/records/display', locals: {
7      record_to_display: record,
8      context: @record_context,
9      flagged: false
10   }
11 end

I'm guessing the error is somewhere in the partial we're rendering (which itself renders additional partials).
Without an accurate line number there's no way to track it down.

Rails version: 5.2.4.4
JBuilder version: 2.10.0

@duhaime
Copy link

duhaime commented Apr 4, 2023

I had the same issue, so I stopped the server, stopped spring, then restarted the server and all was well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants