feat(agentflow): add requestInterceptor prop for API customization#5936
feat(agentflow): add requestInterceptor prop for API customization#5936jocelynlin-wd merged 3 commits intomainfrom
Conversation
- Introduced a new `requestInterceptor` prop in the Agentflow component to allow users to customize outgoing API requests. - Updated relevant components and types to support the new interceptor functionality. - Enhanced the API client to handle the interceptor and log errors if thrown during request processing. - Added tests to ensure the interceptor works as expected and does not recreate the client unnecessarily.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
- Rearranged the export order of types in index.ts for better readability. - Removed unused ApiContextValue interface from api.ts to streamline API types. - Ensured ApiResponse and ValidationError are correctly positioned in the type exports.
There was a problem hiding this comment.
Code Review
This pull request introduces a new requestInterceptor prop to the Agentflow component, enabling customization of outgoing API requests. While this enhances flexibility, it also introduces a significant security risk, as an untrusted or compromised interceptor could manipulate sensitive request configurations, including authentication tokens, potentially leading to data exfiltration or unauthorized actions. This aligns with Rule 5's emphasis on secure authentication flows. Consumers must carefully vet any provided interceptor functions and adhere to security best practices. Additionally, the documentation for this new prop needs improvement, particularly regarding its use for re-enabling cookie-based authentication, which is crucial for maintaining correct authentication flows as per Rule 5. The PR also includes a beneficial refactoring of TypeScript type definitions.
jhead
left a comment
There was a problem hiding this comment.
lgtm. I agree with your comment re: trust @jocelynlin-wd
requestInterceptorprop in the Agentflow component to allow users to customize outgoing API requests.Before:

The change in #5919 no longer allows token to work.
After:
