Skip to content

Commit

Permalink
fix (ai/core): Add null check for OTEL attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kdawgwilk committed Feb 8, 2025
1 parent eb99d48 commit be01951
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ it('should handle mixed attribute types correctly', () => {
input: { input: () => 'input value' },
output: { output: () => 'output value' },
undefined: undefined,
someNull: null,
},
});
expect(result).toEqual({
Expand Down
5 changes: 3 additions & 2 deletions packages/ai/core/telemetry/select-telemetry-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function selectTelemetryAttributes({
| AttributeValue
| { input: () => AttributeValue | undefined }
| { output: () => AttributeValue | undefined }
| undefined;
| undefined
| null;
};
}): Attributes {
// when telemetry is disabled, return an empty object to avoid serialization overhead:
Expand All @@ -20,7 +21,7 @@ export function selectTelemetryAttributes({
}

return Object.entries(attributes).reduce((attributes, [key, value]) => {
if (value === undefined) {
if (value === undefined || value === null) {
return attributes;
}

Expand Down

0 comments on commit be01951

Please sign in to comment.