Skip to content

[Components] Brave Search API #17704 #17839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2025
Merged

[Components] Brave Search API #17704 #17839

merged 2 commits into from
Aug 6, 2025

Conversation

lcaresia
Copy link
Collaborator

@lcaresia lcaresia commented Jul 29, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Introduced integration with the Brave Search API, enabling users to perform web searches directly within the app.
    • Added configurable search options, including query, country, search language, UI language, and SafeSearch filter.
  • Chores

    • Updated package version and dependencies for improved compatibility and stability.

@lcaresia lcaresia self-assigned this Jul 29, 2025
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

Walkthrough

A Brave Search API integration was implemented, introducing a new web search action, a structured API client, and supporting constant definitions. The integration includes paginated search logic, configurable parameters, and proper authentication. Additionally, package metadata was updated with versioning, dependencies, and corrected JSON structure.

Changes

Cohort / File(s) Change Summary
Web Search Action
components/brave_search_api/actions/web-search/web-search.mjs
Introduced a new "Web Search" action module for the Brave Search API. Defines metadata, parameter properties, and an async run method that performs up to 5 paginated search requests, aggregating results and returning a summary.
API Client Implementation
components/brave_search_api/brave_search_api.app.mjs
Expanded the Brave Search API app integration with detailed prop definitions for search parameters, and implemented methods for base URL retrieval, authenticated HTTP requests, and the main web search operation.
Constant Definitions
components/brave_search_api/common/constants.mjs
Added a new module exporting constant arrays for country codes, language codes, UI locale codes, and SafeSearch options, used for parameter selection in the integration.
Package Metadata
components/brave_search_api/package.json
Updated the package version, added a dependency on "@pipedream/platform", and fixed JSON structure by closing the "publishConfig" object properly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebSearchAction
    participant BraveSearchAPIApp
    participant BraveSearchAPI

    User->>WebSearchAction: Trigger "Web Search" with parameters
    WebSearchAction->>BraveSearchAPIApp: Call webSearch() with query, country, etc.
    loop up to 5 times (pagination)
        BraveSearchAPIApp->>BraveSearchAPI: HTTP GET /web/search (with params, headers)
        BraveSearchAPI-->>BraveSearchAPIApp: Return search results
        BraveSearchAPIApp-->>WebSearchAction: Return results for this page
    end
    WebSearchAction-->>User: Return aggregated results and summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Poem

In the warren of code, a search rabbit hops,
Through constants and queries, it never stops.
Brave new actions, results in a heap,
Country and language—options so deep!
Version bumped, dependencies in tow,
Now web-searching wonders are ready to go.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-17704

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lcaresia lcaresia linked an issue Jul 29, 2025 that may be closed by this pull request
Copy link

vercel bot commented Jul 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2025 1:49pm
pipedream-docs ⬜️ Ignored (Inspect) Aug 5, 2025 1:49pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Aug 5, 2025 1:49pm

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
components/brave_search_api/brave_search_api.app.mjs (2)

46-63: Consider adding error handling to the request method

The _makeRequest method follows standard patterns but could benefit from more specific error handling for API-specific responses.

  async _makeRequest(opts = {}) {
    const {
      $ = this,
      path,
      headers,
      ...otherOpts
    } = opts;
-   return axios($, {
+   try {
+     return await axios($, {
+       ...otherOpts,
+       url: this._baseUrl() + path,
+       headers: {
+         "x-subscription-token": `${this.$auth.api_key}`,
+         "accept": "application/json",
+         "accept-encoding": "gzip",
+         ...headers,
+       },
+     });
+   } catch (error) {
+     throw new Error(`Brave Search API request failed: ${error.message}`);
+   }
+ },

65-70: Add parameter validation to webSearch method

Consider adding basic parameter validation to ensure required parameters are provided.

  async webSearch(args = {}) {
+   const { params = {} } = args;
+   if (!params.q) {
+     throw new Error("Query parameter 'q' is required for web search");
+   }
    return this._makeRequest({
      path: "/web/search",
      ...args,
    });
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3452ab6 and 5b62a9c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/brave_search_api/actions/web-search/web-search.mjs (1 hunks)
  • components/brave_search_api/brave_search_api.app.mjs (1 hunks)
  • components/brave_search_api/common/constants.mjs (1 hunks)
  • components/brave_search_api/package.json (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
components/brave_search_api/actions/web-search/web-search.mjs (2)

Learnt from: GTFalcao
PR: #12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-10-08T15:33:38.240Z
Learning: When exporting a summary message in the run method of an action, ensure the message is correctly formatted. For example, in the hackerone-get-members action, the correct format is Successfully retrieved ${response.data.length} members.

Learnt from: GTFalcao
PR: #12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the run method of an action, ensure the message is correctly formatted. For example, in the hackerone-get-members action, the correct format is Successfully retrieved ${response.data.length} members.

components/brave_search_api/package.json (1)

Learnt from: jcortes
PR: #14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like fs to package.json dependencies, as they are native modules provided by the Node.js runtime.

components/brave_search_api/brave_search_api.app.mjs (1)

Learnt from: GTFalcao
PR: #16954
File: components/salesloft/salesloft.app.mjs:14-23
Timestamp: 2025-06-04T17:52:05.780Z
Learning: In the Salesloft API integration (components/salesloft/salesloft.app.mjs), the _makeRequest method returns response.data which directly contains arrays for list endpoints like listPeople, listCadences, listUsers, and listAccounts. The propDefinitions correctly call .map() directly on these responses without needing to destructure a nested data property.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (5)
components/brave_search_api/common/constants.mjs (1)

1-513: Well-structured constants module

The constants are well-organized and provide comprehensive coverage for the API parameters. The consistent object structure with label and value properties makes them suitable for UI dropdown options.

components/brave_search_api/package.json (2)

3-3: Appropriate version bump for new integration

Version update to 0.1.0 is appropriate for a new component integration.


14-17: Correct JSON structure and dependencies

The missing closing brace has been properly added, and the platform dependency is correctly specified for Pipedream components.

components/brave_search_api/brave_search_api.app.mjs (1)

7-41: Well-structured property definitions

The property definitions effectively utilize the constants module and follow Pipedream conventions with appropriate labels, descriptions, and optional flags.

components/brave_search_api/actions/web-search/web-search.mjs (1)

9-41: Property definitions correctly structured

The property definitions properly reference the app's propDefinitions, maintaining consistency and reusability across the integration.

Comment on lines +128 to +130
label: "Sweden",
value: "SV",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect country code for Sweden

Sweden's ISO 3166-1 alpha-2 country code should be "SE", not "SV".

    {
      label: "Sweden",
-     value: "SV",
+     value: "SE",
    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
label: "Sweden",
value: "SV",
},
{
label: "Sweden",
value: "SE",
},
🤖 Prompt for AI Agents
In components/brave_search_api/common/constants.mjs around lines 128 to 130, the
country code for Sweden is incorrectly set to "SV". Update the value from "SV"
to the correct ISO 3166-1 alpha-2 code "SE" to fix this.

Comment on lines +250 to +252
label: "Japanese",
value: "jp",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect language code for Japanese

Japanese language code should be "ja" according to ISO 639-1, not "jp".

    {
      label: "Japanese",
-     value: "jp",
+     value: "ja",
    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
label: "Japanese",
value: "jp",
},
{
label: "Japanese",
value: "ja",
},
🤖 Prompt for AI Agents
In components/brave_search_api/common/constants.mjs around lines 250 to 252, the
language code for Japanese is incorrectly set to "jp". Update the value from
"jp" to the correct ISO 639-1 code "ja" to fix this issue.

jcortes
jcortes previously approved these changes Jul 30, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lcaresia lgtm! Ready for QA!

@lcaresia
Copy link
Collaborator Author

lcaresia commented Aug 5, 2025

/approve

@lcaresia lcaresia merged commit 146894b into master Aug 6, 2025
11 checks passed
@lcaresia lcaresia deleted the issue-17704 branch August 6, 2025 13:50
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.

[Components] Brave Search API
2 participants