Skip to content

Metadata field in ragText.add() is required and saved as {} instead of being optional #34

@franckdsf

Description

@franckdsf

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.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions