Truncating some field in log

I am using fluentd for shipping my logs to AWS CloudWatch. Currently, my log lines are toooooooo big (1M or more)
AWS CloudWatch has a 256KB per row size limit, and large rows are rejected by CloudWatch after FlunetD has sent them there.
For solving this issue I am going to truncate the “message” field to 250000 symbols like that:

      <filter **>
        @type record_transformer
        enable_ruby true
        auto_typecast true
        <record>
          message ${record["message"][0..250000]}
        </record>
      </filter>

And it works. BUT only if the “message” field is present in a log structure. Otherwise - I get an error:

2021-04-27 07:15:49 +0000 [warn]: #0 dump an error event: error_class=RuntimeError error="failed to expand `record[\"message\"][0..250000]` : error = undefined method `[]' for nil:NilClass" location="/fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.12.2/lib/fluent/plugin/filter_record_transformer.rb:310:in `rescue in expand'" tag=

If it is okay to assign a default value to message, the following sample may work.

<filter **>
  @type record_transformer
  enable_ruby
  <record>
    message ${record.dig("message") ? record["message"][0..250000] : ""}
  </record>
</filter>

FYI: record_transformer - Fluentd