Skip to content

fix: DatasetCase.metadata() always empty when fetching dataset rows from Braintrust#126

Merged
Andrew Kent (realark) merged 1 commit into
braintrustdata:mainfrom
Planview-JamesK:fix/dataset-metadata-empty
Jun 18, 2026
Merged

fix: DatasetCase.metadata() always empty when fetching dataset rows from Braintrust#126
Andrew Kent (realark) merged 1 commit into
braintrustdata:mainfrom
Planview-JamesK:fix/dataset-metadata-empty

Conversation

@Planview-JamesK

Copy link
Copy Markdown
Contributor

Fixes #125

Problem

When running a remote eval that fetches dataset rows from Braintrust (e.g. a dataset assigned in the Playground UI), DatasetCase.metadata() returns an empty map for every row — even though the rows have metadata set. The same experiment works correctly with the TypeScript CLI.

Root Cause

InsertProjectLogsEventMetadata extends HashMap<String, Object> and also declares a separate additionalProperties field. Jackson deserializes unknown properties (all custom metadata keys) into the HashMap base, not into the additionalProperties field. DatasetBrainstoreImpl was calling metadataObj.getAdditionalProperties(), which is always empty.

Fix

Copy entries from the HashMap base via new HashMap<>(metadataObj) instead of calling getAdditionalProperties().

// Before:
Map<String, Object> metadata =
        metadataObj != null ? metadataObj.getAdditionalProperties() : Map.of();
if (metadata == null) metadata = Map.of();

// After:
Map<String, Object> metadata = metadataObj != null ? new HashMap<>(metadataObj) : Map.of();

Verification

Confirmed by running a playground experiment against a Braintrust dataset with metadata fields. After the fix, DatasetCase.metadata() correctly returns the row's metadata keys. Before the fix, metadata_keys=[] for every dataset-fetched row.

InsertProjectLogsEventMetadata extends HashMap<String,Object> and also
declares a separate additionalProperties field. Jackson deserializes
unknown properties (all custom metadata keys) into the HashMap base,
not into the additionalProperties field.

DatasetBrainstoreImpl called metadataObj.getAdditionalProperties(),
which is always empty, so DatasetCase.metadata() returned an empty map
for every row fetched from Braintrust.

Fix: copy entries from the HashMap base via new HashMap<>(metadataObj).
@realark

Copy link
Copy Markdown
Collaborator

thanks for flagging this James Kennedy (@Planview-JamesK) , I'll get this merged and released tomorrow

@realark Andrew Kent (realark) merged commit 12626c9 into braintrustdata:main Jun 18, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatasetCase.metadata() always empty when fetching dataset rows from Braintrust

2 participants