Skip to content

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Jul 30, 2025

Resolves #17856

Summary by CodeRabbit

  • New Features

    • The HTML to PDF action now supports saving the generated PDF to a specified local file path and includes a writable directory option.
    • PDF generation returns both the base64 string and local file path when saved, along with a summary message.
  • Improvements

    • Screenshot action updated to wait for a specific DOM selector with simplified configuration.
    • URL scraping actions now process URLs sequentially for more immediate results.
    • Browserless API base URL handling improved to require updated authentication configuration.
  • Chores

    • Updated version numbers for several Browserless actions and dependencies.

Copy link

vercel bot commented Jul 30, 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 1, 2025 3:25pm
pipedream-docs ⬜️ Ignored (Inspect) Aug 1, 2025 3:25pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Aug 1, 2025 3:25pm

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

The updates refactor the Browserless integration to dynamically use the base_url from authentication for API requests, replacing hardcoded endpoints. The convert-html-to-pdf action now leverages a new convertHtmlToPdf method and supports saving PDFs locally. Several action version numbers are incremented, and dependencies in package.json are updated.

Changes

Cohort / File(s) Change Summary
Convert HTML to PDF Action
components/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs
Refactored to use browserless.convertHtmlToPdf method, removed direct axios usage, added support for downloadPath and syncDir, introduced file saving to /tmp, updated return structure, and bumped version to 0.4.2.
Browserless App Logic
components/browserless/browserless.app.mjs
Changed _baseUrl to use dynamic base_url from auth with error if missing, added convertHtmlToPdf method for PDF generation via POST request with arraybuffer response.
Action Version Bumps and Prop Updates
components/browserless/actions/scrape-url-list/scrape-url-list.mjs, components/browserless/actions/scrape-url/scrape-url.mjs, components/browserless/actions/take-screenshot/take-screenshot.mjs
Incremented version numbers for scrape-url-list (0.0.2 → 0.0.3), scrape-url (0.0.2 → 0.0.3), and take-screenshot (0.5.4 → 0.5.5). Renamed waitFor to waitForSelector in take-screenshot, updated related logic and descriptions.
Package Metadata
components/browserless/package.json
Updated package version (0.1.3 → 0.1.4) and bumped @pipedream/platform dependency (^1.5.1 → ^3.1.0).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConvertHtmlToPdfAction
    participant BrowserlessApp
    participant FileSystem

    User->>ConvertHtmlToPdfAction: Provide HTML and options (downloadPath, etc.)
    ConvertHtmlToPdfAction->>BrowserlessApp: convertHtmlToPdf(opts)
    BrowserlessApp->>BrowserlessApp: POST to {base_url}/pdf
    BrowserlessApp-->>ConvertHtmlToPdfAction: PDF binary (arraybuffer)
    alt downloadPath specified
        ConvertHtmlToPdfAction->>FileSystem: Save PDF to /tmp or syncDir
        FileSystem-->>ConvertHtmlToPdfAction: File path
    end
    ConvertHtmlToPdfAction-->>User: Return base64 PDF (and file path if saved)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Assessment against linked issues

Objective Addressed Explanation
Use dynamic base_url from connection/auth for Browserless API requests instead of legacy endpoint (#17856)
Remove hardcoded endpoints and ensure all requests route to the correct, user-configurable base URL (#17856)
Add support for new connection property (base_url) in Browserless app (#17856)

Poem

A bunny hopped through code so bright,
Rewiring endpoints left and right.
No more legacy 403s,
Dynamic URLs with ease!
PDFs saved with a cheerful cheer,
Version bumps bring springtime near.
🐰✨

Note

⚡️ Unit Test Generation is now available in beta!

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


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 37bff14 and afaccad.

📒 Files selected for processing (1)
  • components/browserless/actions/take-screenshot/take-screenshot.mjs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/browserless/actions/take-screenshot/take-screenshot.mjs
⏰ 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: pnpm publish
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
✨ 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-17856

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.

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: 0

🧹 Nitpick comments (2)
components/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs (2)

29-37: Minor suggestion: Update parameter name for clarity.

The method implementation is correct and follows the established pattern from other actions. However, consider renaming the parameter from screenshot to data or pdfData for better clarity since this method handles PDF data.

-    async downloadToTMP(screenshot) {
+    async downloadToTMP(data) {
       const path = this.downloadPath.includes("/tmp")
         ? this.downloadPath
         : `/tmp/${this.downloadPath}`;
-      fs.writeFileSync(path, screenshot);
+      fs.writeFileSync(path, data);
       return path;
     },

41-61: LGTM: Successfully implements PR objectives with proper functionality.

The refactoring from direct axios calls to using this.browserless.convertHtmlToPdf successfully addresses the PR objective of using dynamic base_url handling instead of hardcoded endpoints. The implementation correctly:

  • Leverages the app method for proper base_url handling
  • Converts binary data to base64 for API response
  • Conditionally saves files when downloadPath is provided
  • Exports appropriate success summary

Consider adding explicit error handling around the app method call and file operations for better robustness.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a5a1152 and 8824f5d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs (1 hunks)
  • components/browserless/actions/scrape-url-list/scrape-url-list.mjs (1 hunks)
  • components/browserless/actions/scrape-url/scrape-url.mjs (1 hunks)
  • components/browserless/actions/take-screenshot/take-screenshot.mjs (1 hunks)
  • components/browserless/browserless.app.mjs (2 hunks)
  • components/browserless/package.json (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
components/browserless/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/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs (1)

Learnt from: js07
PR: #17375
File: components/tinypng/actions/compress-image/compress-image.mjs:18-23
Timestamp: 2025-07-01T17:01:46.327Z
Learning: In TinyPNG compress-image action (components/tinypng/actions/compress-image/compress-image.mjs), the syncDir property uses accessMode: "read" because this action only reads input files and returns API responses without writing files to /tmp, unlike other TinyPNG actions that save processed files to disk.

🧬 Code Graph Analysis (1)
components/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs (1)
components/browserless/actions/take-screenshot/take-screenshot.mjs (3)
  • screenshot (45-53)
  • path (37-39)
  • filePath (61-61)
🔇 Additional comments (10)
components/browserless/actions/scrape-url-list/scrape-url-list.mjs (1)

7-7: LGTM: Version increment aligns with coordinated release.

The version bump from "0.0.2" to "0.0.3" is appropriate for this coordinated release that addresses the base URL issue.

components/browserless/actions/take-screenshot/take-screenshot.mjs (1)

8-8: LGTM: Appropriate patch version increment.

The version bump from "0.5.4" to "0.5.5" correctly follows semantic versioning for this coordinated release.

components/browserless/browserless.app.mjs (2)

9-9: Excellent fix: Dynamic base URL resolves the legacy endpoint issue.

This change directly addresses the PR objective by making the base URL dynamic from the authentication configuration (this.$auth.base_url) instead of using a hardcoded URL. This prevents the 403 errors caused by routing to the legacy endpoint.


53-60: LGTM: Well-implemented convertHtmlToPdf method.

The new method follows the established pattern in this class:

  • Uses the _makeRequest helper consistently
  • Sets appropriate responseType: "arraybuffer" for PDF content
  • Allows options to be passed through and merged properly
components/browserless/actions/scrape-url/scrape-url.mjs (1)

7-7: LGTM: Consistent version increment.

The version bump from "0.0.2" to "0.0.3" is consistent with the other actions in this coordinated release.

components/browserless/package.json (2)

3-3: LGTM: Package version increment aligns with changes.

The version bump to 0.1.4 appropriately reflects the new convertHtmlToPdf method and base URL fix.


16-16: Verify compatibility with major @pipedream/platform update in browserless component

We bumped @pipedream/platform from ^1.5.1 to ^3.1.0 in components/browserless/package.json. Major releases may include breaking changes to core APIs (defineComponent signature, built-in utilities like axios, $send, $checkpoint, $render, or this.$auth). Please:

  • Search for every import/use of @pipedreamhq/platform in components/browserless (both require and ES import).
  • Verify defineComponent usage still matches the new signature.
  • Ensure any calls to platform utilities (axios, $send, $checkpoint, $render, this.$auth) conform to v3 behavior.
  • Run the browserless component’s tests and confirm there are no failures.

Example commands:

rg "@pipedreamhq/platform" -n components/browserless
rg "defineComponent"     -n components/browserless
npm run test -- components/browserless
components/browserless/actions/convert-html-to-pdf/convert-html-to-pdf.mjs (3)

1-2: LGTM: Import changes support the refactoring objective.

The switch from axios to the browserless app import and addition of fs for file operations aligns with the PR's goal of using dynamic base_url handling instead of hardcoded endpoints.


8-8: LGTM: Appropriate version increment.

The minor version bump from 0.4.1 to 0.4.2 is appropriate for the refactoring and new download functionality added.


11-11: LGTM: Props correctly configured for new functionality.

The browserless app prop enables proper base_url handling, and the new download-related props are well-configured:

  • downloadPath is appropriately optional
  • syncDir correctly uses accessMode: "write" for file operations
  • Descriptions are clear and accurate

Also applies to: 17-28

lcaresia
lcaresia previously approved these changes Jul 31, 2025
@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit ebbc0e6 into master Aug 4, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-17856 branch August 4, 2025 15: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.

[BUG] Browserless Integration Using Legacy Endpoint - Causing 403 Errors
2 participants