Skip to content

Rescue JSON::ParserError in object_address_for - #321

Open
lyn1dev wants to merge 1 commit into
splitwise:mainfrom
lyn1dev:fix/rescue-json-parser-error-object-address
Open

lyn1dev wants to merge 1 commit into
splitwise:mainfrom
lyn1dev:fix/rescue-json-parser-error-object-address

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 26, 2026

Copy link
Copy Markdown

Summary

  • Rescue JSON::ParserError in SuperDiff::Core::Helpers#object_address_for (on Ruby >= 2.7.0) and return '' when ObjectSpace.dump emits non-JSON output such as "100000." for large Float values (e.g. 100_000.1).
  • Also return '' when the parsed JSON hash does not include an 'address' key (e.g. static/dynamic Symbol objects), avoiding an ArgumentError in Integer(nil, 16).

Testing

  • Added unit tests in spec/unit/core/helpers_spec.rb for 100_000.1, -100_000.1, and :sym.
  • Verified the new tests fail without the fix (JSON::ParserError: invalid number: '100000.' and ArgumentError: base specified for non string value) and pass with the fix (BUNDLE_GEMFILE=gemfiles/no_rails_rspec_gte_3_13.gemfile bundle exec rspec spec/unit/core/helpers_spec.rb: 14 examples, 0 failures, run on Windows with a preload overriding WarningsLogger::Spy#capture_warnings to reopen the open warnings_file IO instead of reopening by path).
  • Ran SuperDiff.diff(1.0, 100_000.1), which raised JSON::ParserError before the fix and returns " #<Float: {\n }>" after.
  • Ran bundle exec rspec spec/unit (455 examples, 5 pre-existing Windows environment failures around local timezone ric vs CDT and non-TTY ANSI codes, matching the unmodified checkout baseline).
  • Ran bundle exec rubocop lib/super_diff/core/helpers.rb spec/unit/core/helpers_spec.rb (2 files inspected, no offenses detected).

Fixes #162

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

A failing spec with expect(value).to eq 1.0 raises JSON::ParserError

1 participant