fix(netlify): safely access optional logger
PR Checklist
Please check if your PR fulfills the following requirements:
- The commit message follows the contribution guidelines
Bugs / Features
- Related issue(s) linked
- Tests for the changes have been added
- Docs have been added / updated
- Changeset has been added
What is the current behavior?
The Netlify Functions example fails to compile because context.logger
can be undefined.
TypeScript reports:
'context.logger' is possibly 'undefined'
What is the new behavior?
The logger is accessed using optional chaining:
context?.logger?.info(`Fetching weather for ${location}`);
This allows the Netlify Functions example to compile even when the logger
is unavailable.
Testing
Ran:
pnpm --filter voltagent-example-netlify-functions build
The build completed successfully.
Notes for reviewers
This is a small TypeScript safety fix. No public API or package behavior was changed.
Summary by cubic
Fixes a TypeScript compile error in the Netlify Functions example by safely accessing the optional logger. Uses context?.logger?.info(...) so the example builds successfully even when a logger is unavailable. No public API or package behavior changes; only the example code is affected.
Summary by CodeRabbit
- Bug Fixes
- Improved weather tool reliability by preventing errors when optional logging context is unavailable.