)]}'
{
  "commit": "34908e28983f1db5572e1fdf7c5a89a8b06c5f9a",
  "tree": "36a866f426ac0dff7d420855dd761b2b0fca6edd",
  "parents": [
    "2d7376ea378b14548b1d417df285a0a5c84957ba"
  ],
  "author": {
    "name": "Iori IKEDA",
    "email": "8983747+NotFounds@users.noreply.github.com",
    "time": "Thu Dec 14 08:02:45 2023 -0800"
  },
  "committer": {
    "name": "Copybara-Service",
    "email": "copybara-worker@google.com",
    "time": "Thu Dec 14 08:06:37 2023 -0800"
  },
  "message": "Fix TypeError when passing an instance of a subclass of String to a string field (#13818)\n\n## Issue\nWhen an object that is an instance of a string-derived class is passed to a string field in a protobuf message in Ruby, it results in a ﻿`Google::Protobuf::TypeError`.\n\n### Steps to reproduce\n```rb\n~/src/github.com/protocolbuffers/protobuf/ruby/tests ❯❯❯ irb -I .\nirb(main):001:0\u003e require \u0027basic_test_pb\u0027\n\u003d\u003e true\nirb(main):002:0\u003e myString \u003d Class.new(String)\n\u003d\u003e #\u003cClass:0x00000001531540d8\u003e\nirb(main):003:0\u003e str \u003d myString.new(\"foo\")\n\u003d\u003e \"foo\"\nirb(main):004:0\u003e BasicTest::TestMessage.new(optional_string: \"foo\")\n\u003d\u003e \u003cBasicTest::TestMessage: optional_string: \"foo\", repeated_int32: [], repeated_int64: [], repeated_uint32: [], repeated_uint64: [], repeated_bool: [], repeated_float: [], repeated_double: [], repeated_string: [], repeated_bytes: [], repeated_msg: [], repeated_enum: []\u003e\nirb(main):005:0\u003e BasicTest::TestMessage.new(optional_string: str)\n(irb):5:in `initialize\u0027: Invalid argument for string field \u0027optional_string\u0027 (given #\u003cClass:0x00000001531540d8\u003e). (Google::Protobuf::TypeError)\nirb(main):006:0\u003e\n```\n\n## Fix\nThe issue appears to be caused by the field checking mechanism not properly handling instances of classes that inherit from basic types like String. My proposed solution is to improve the type checking for string fields to consider not just ﻿String instances but also instances of subclasses of ﻿String.\n\n## Impact\nThe changes will allow instances of classes derived from ﻿String to be passed to string fields without any error.\nThis is a backwards-compatible change and will not affect the existing behaviour with standard ﻿String instances.\n\nCloses #13818\n\nCOPYBARA_INTEGRATE_REVIEW\u003dhttps://github.com/protocolbuffers/protobuf/pull/13818 from NotFounds:support-string-subclass-for-ruby 2d2796c4f96d5a182a269b54e893f436f2211ea2\nPiperOrigin-RevId: 590941235\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "c9448cde01d7a6f225c2bc67d748a4098de4f23a",
      "old_mode": 33188,
      "old_path": "ruby/ext/google/protobuf_c/convert.c",
      "new_id": "b97c050580b8c15dc71a18ea6fc2d1bd2efcf754",
      "new_mode": 33188,
      "new_path": "ruby/ext/google/protobuf_c/convert.c"
    },
    {
      "type": "modify",
      "old_id": "fe2119e42fb78238d049efec59f778059221ab4a",
      "old_mode": 33261,
      "old_path": "ruby/tests/basic.rb",
      "new_id": "1e5e7a341d176fbef365e8edfd79a6ba276eb494",
      "new_mode": 33261,
      "new_path": "ruby/tests/basic.rb"
    }
  ]
}
