Skip to content

JSON.dump raises Encoding::UndefinedConversionError #8682

@nobu

Description

@nobu

In RDoc test, Encoding::UndefinedConversionError occurred at JSON.dump to the IO which has been set_encoding(Encoding::UTF_8).
\xE2 seems the first byte of U+2026;HORIZONTAL ELLIPSIS (\xe2\x80\xa6), inserted because a long text is truncated.

https://github.com/ruby/rdoc/actions/runs/13721925009/job/38379134922#step:5:22

Error: test_meta_tags_for_markdwon_files_paragraph(RDocGeneratorDarkfishTest): Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
org/jruby/RubyIO.java:1640:in `write'
org/jruby/RubyIO.java:1613:in `write'
json/ext/GeneratorState.java:237:in `generate'
json/ext/GeneratorState.java:141:in `generate'
/home/runner/work/rdoc/rdoc/vendor/bundle/jruby/3.1.0/gems/json-2.10.1-java/lib/json/common.rb:846:in `dump'
/home/runner/work/rdoc/rdoc/lib/rdoc/generator/json_index.rb:146:in `block in generate'
org/jruby/RubyIO.java:1198:in `open'
/home/runner/work/rdoc/rdoc/lib/rdoc/generator/json_index.rb:142:in `generate'
/home/runner/work/rdoc/rdoc/lib/rdoc/generator/darkfish.rb:233:in `generate'
/home/runner/work/rdoc/rdoc/test/rdoc/test_rdoc_generator_darkfish.rb:461:in `test_meta_tags_for_markdwon_files_paragraph'

I cannot reproduce it locally but suspect locale related conditions.

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)

    jruby 9.4.13.0-SNAPSHOT (3.1.4) 2025-03-06 7fc571bc88 OpenJDK 64-Bit Server VM 17.0.14+7 on 17.0.14+7 +jit [x86_64-linux]
    
  • Operating system and platform (e.g. uname -a)

    GitHub Actions Ubuntu-latest and macOS-latest

  • Environment variables

Expected Behavior

  • CRuby (and TruffleRuby) writes UTF-8 string as JSON successfully.

Actual Behavior

  • Describe or show the actual behavior.
    See above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions