Hey,
When using the ragText.add() helper to add custom embeddings, the metadata field inside the chunks array is required, even when no metadata is needed.
If you pass {}, it gets stored in the database as an empty object instead of being omitted or undefined.
This leads to unnecessary noise in the stored data and complicates downstream logic that checks for the existence of metadata.
Example code
const entry = await ragText.add(ctx, {
key: image.id,
namespace: namespace,
chunks: [
{
text: description,
embedding,
metadata: {}, // Required, otherwise error
},
],
});
Observed behavior
- The
metadata field is required.
- Passing
{} results in the value being stored as {} in the database, even though there’s no metadata.
Expected behavior
metadata should be an optional field in the chunks object.
- If omitted, it should not appear in the database (or be stored as
null / undefined), maintaining cleaner records.
