Error Code 2: Key not found on PUT when the Bin value is null


calling the Put() method with a bin that contain a null item return Error Code 2: Key not found

  1. Is it not possible to store null in a Bin ?
  2. Why it is returning “key not found” ?
  3. Where is the list of C# client error code? “Error Code 2” is just noisy otherwise.



No, storing null in a Bin deletes the bin, the record is also deleted when it’s bin count reaches 0.

You are effectively issuing a delete to a non-existent record.

Not sure if they are defined (@Brian?), a list of server error codes can be found here:

Many thanks for the clarification.


C# client return code are located in Main/ResultCode.cs.

How to avoid this, is there any policy exists

Any deletes to a non-existent record will result in a not-found result code. If this is expected for the operation then you should handle this result similar/same as a success.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.