nats-io/natscli

Max Message Size accepts too large a value

scottf opened this issue · 2 comments

Observed behavior

max_msg_size is an int32. max-value-size in kv uses max_msg_size under the covers. This kv add should fail.

C:\nats>nats kv add --max-value-size=9999999999 --storage=file exampleBucket
Information for Key-Value Store Bucket exampleBucket created 2024-06-18T10:43:00-04:00

Configuration:

          Bucket Name: exampleBucket
         History Kept: 1
        Values Stored: 0
           Compressed: false
   Backing Store Kind: JetStream
          Bucket Size: 0 B
  Maximum Bucket Size: unlimited
   Maximum Value Size: 1.3 GiB
          Maximum Age: unlimited
     JetStream Stream: KV_exampleBucket
              Storage: File

Cluster Information:

                 Name:
               Leader: NCLLR6KQWZ2MKGSOOWCAG4HPG7VB37GSOWQJUKDQLZQETWJEGHIFBWAQ

C:\nats>nats s info KV_exampleBucket
Information for Stream KV_exampleBucket created 2024-06-18 10:43:00

              Subjects: $KV.exampleBucket.>
              Replicas: 1
               Storage: File

Options:

             Retention: Limits
       Acknowledgments: true
        Discard Policy: New
      Duplicate Window: 2m0s
            Direct Get: true
     Allows Msg Delete: false
          Allows Purge: true
        Allows Rollups: true

Limits:

      Maximum Messages: unlimited
   Maximum Per Subject: 1
         Maximum Bytes: unlimited
           Maximum Age: unlimited
  Maximum Message Size: 1.3 GiB
     Maximum Consumers: unlimited

State:

              Messages: 0
                 Bytes: 0 B
        First Sequence: 0
         Last Sequence: 0
      Active Consumers: 0

Expected behavior

This kv add should fail. 9999999999 is about 9 GiB. The max is 2147483647 bytes.

Server and client version

Latest/Recent

Host environment

N/A

Steps to reproduce

See explanation

Fixed in #1078

Stream related fix in #1079