-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add Screenshotbase app and Take actions (GET /v1/take) #18663
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
WalkthroughAdds a new Screenshotbase app integration with auth, base URL helper, and connection test, plus four new actions to capture screenshots: basic capture, advanced capture, HTML-to-image, and URL-to-PDF. Each action builds params, calls GET {base}/v1/take with apikey header, exports "result", and returns the response. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User (Pipedream)
participant A as Action (Capture/Advanced/HTML/PDF)
participant APP as Screenshotbase App (baseUrl)
participant API as Screenshotbase API
U->>A: Provide props (url/html, viewport, format, flags)
A->>APP: baseUrl()
APP-->>A: https://api.screenshotbase.com or custom
A->>API: GET {base}/v1/take<br/>headers: apikey<br/>query: params
API-->>A: Response (image/pdf bytes or JSON)
A-->>U: $.export("result", res) and return
note over A,API: No explicit error handling in actions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (6)
components/screenshotbase/screenshotbase.app.mjs (1)
32-34
: Consider validating the base URL format.The
baseUrl()
method trims whitespace but doesn't validate that the result is a well-formed URL. Whileaxios
will throw if the URL is invalid, adding validation here would provide clearer error messages to users.Consider adding URL validation:
baseUrl() { - return this.$auth.base_url?.trim() || "https://api.screenshotbase.com"; + const url = this.$auth.base_url?.trim() || "https://api.screenshotbase.com"; + try { + new URL(url); + return url; + } catch (e) { + throw new Error(`Invalid base_url: ${url}`); + } },components/screenshotbase/actions/capture/capture.mjs (1)
53-53
: Remove unusedsteps
parameter.The
steps
parameter is declared but never used in the function body.Apply this diff:
- async run({ steps, $ }) { + async run({ $ }) {components/screenshotbase/actions/take_html/take_html.mjs (1)
12-12
: Consider validating the HTML input.The
html
prop is marked as required but doesn't validate that the input contains actual HTML content. Users could accidentally submit empty or whitespace-only strings, leading to API errors.Add validation in the prop definition:
- html: { label: "HTML", type: "string", optional: false }, + html: { + label: "HTML", + type: "string", + optional: false, + description: "Raw HTML to render as a screenshot", + },Or add validation in the
run
method:async run({ $ }) { + if (!this.html?.trim()) { + throw new Error("HTML content cannot be empty"); + } const base = this.screenshotbase.baseUrl();components/screenshotbase/actions/take_pdf/take_pdf.mjs (1)
12-12
: Consider validating the URL input.The
url
prop is required but doesn't validate that it's a well-formed URL. This could lead to confusing API errors if users provide invalid input.Add validation:
- url: { label: "URL", type: "string", optional: false }, + url: { + label: "URL", + type: "string", + optional: false, + description: "Website URL to render as PDF (must include protocol, e.g., https://)", + },Or validate in the
run
method:async run({ $ }) { + try { + new URL(this.url); + } catch (e) { + throw new Error(`Invalid URL: ${this.url}`); + } const base = this.screenshotbase.baseUrl();components/screenshotbase/actions/take_advanced/take_advanced.mjs (2)
12-12
: Consider validating the URL input.Same as other actions: the
url
prop doesn't validate that it's well-formed. See the comment ontake_pdf.mjs
for suggested validation approaches.
14-14
: Document quality parameter constraints.The
quality
prop is labeled "jpg/jpeg only" but doesn't enforce this constraint or document the valid range (typically 1-100). Consider adding validation or at least a clearer description.- quality: { label: "Quality (jpg/jpeg only)", type: "integer", optional: true }, + quality: { + label: "Quality (jpg/jpeg only)", + type: "integer", + optional: true, + description: "Quality setting 1-100 (only applies when format is jpg or jpeg)", + min: 1, + max: 100, + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
components/screenshotbase/actions/capture/capture.mjs
(1 hunks)components/screenshotbase/actions/take_advanced/take_advanced.mjs
(1 hunks)components/screenshotbase/actions/take_html/take_html.mjs
(1 hunks)components/screenshotbase/actions/take_pdf/take_pdf.mjs
(1 hunks)components/screenshotbase/screenshotbase.app.mjs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/screenshotbase/actions/take_advanced/take_advanced.mjs (3)
components/screenshotbase/actions/capture/capture.mjs (3)
base
(54-54)params
(55-61)res
(62-67)components/screenshotbase/actions/take_html/take_html.mjs (3)
base
(18-18)params
(19-24)res
(25-30)components/screenshotbase/actions/take_pdf/take_pdf.mjs (3)
base
(17-17)params
(18-23)res
(24-29)
components/screenshotbase/actions/take_pdf/take_pdf.mjs (3)
components/screenshotbase/actions/capture/capture.mjs (3)
base
(54-54)params
(55-61)res
(62-67)components/screenshotbase/actions/take_advanced/take_advanced.mjs (3)
base
(20-20)params
(21-28)res
(29-34)components/screenshotbase/actions/take_html/take_html.mjs (3)
base
(18-18)params
(19-24)res
(25-30)
components/screenshotbase/actions/take_html/take_html.mjs (3)
components/screenshotbase/actions/capture/capture.mjs (3)
base
(54-54)params
(55-61)res
(62-67)components/screenshotbase/actions/take_advanced/take_advanced.mjs (3)
base
(20-20)params
(21-28)res
(29-34)components/screenshotbase/actions/take_pdf/take_pdf.mjs (3)
base
(17-17)params
(18-23)res
(24-29)
components/screenshotbase/actions/capture/capture.mjs (3)
components/screenshotbase/actions/take_advanced/take_advanced.mjs (3)
base
(20-20)params
(21-28)res
(29-34)components/screenshotbase/actions/take_html/take_html.mjs (3)
base
(18-18)params
(19-24)res
(25-30)components/screenshotbase/actions/take_pdf/take_pdf.mjs (3)
base
(17-17)params
(18-23)res
(24-29)
🔇 Additional comments (1)
components/screenshotbase/actions/take_html/take_html.mjs (1)
13-13
: Verify inconsistent viewport width default.The default
viewport_width
is 800 here, while other actions (take_pdf, take_advanced) use 1280. If this difference is intentional for HTML rendering, consider adding a comment explaining the rationale; otherwise, align the defaults for consistency.
waitForSelector: { | ||
type: "string", | ||
label: "Wait for CSS Selector", | ||
optional: true, | ||
}, | ||
omitBackground: { | ||
type: "boolean", | ||
label: "Transparent Background", | ||
optional: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Declared props are not sent to the API.
The waitForSelector
and omitBackground
props are declared but never included in the params
object (lines 55-61), meaning users who configure these options will expect them to work but they won't be sent to the Screenshotbase API.
Apply this diff to include the missing parameters:
const params = {
url: this.url,
viewport_width: this.width,
viewport_height: this.height,
format: this.format,
full_page: this.fullPage ? 1 : undefined,
+ wait_for_selector: this.waitForSelector,
+ omit_background: this.omitBackground ? 1 : undefined,
};
Verify the correct parameter names with the Screenshotbase API documentation, as I've assumed snake_case naming convention based on other parameters.
🏁 Script executed:
#!/bin/bash
grep -nR "const params" -n components/screenshotbase/actions/capture/capture.mjs
sed -n '1,200p' components/screenshotbase/actions/capture/capture.mjs | sed -n '50,80p'
Length of output: 550
Pass declared props to the API
Add the missing wait_for_selector
and omit_background
parameters so user‐configured options are sent:
const params = {
url: this.url,
viewport_width: this.width,
viewport_height: this.height,
format: this.format,
full_page: this.fullPage ? 1 : undefined,
+ wait_for_selector: this.waitForSelector,
+ omit_background: this.omitBackground ? 1 : undefined,
};
Verify the exact parameter names against the Screenshotbase API docs.
📝 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.
waitForSelector: { | |
type: "string", | |
label: "Wait for CSS Selector", | |
optional: true, | |
}, | |
omitBackground: { | |
type: "boolean", | |
label: "Transparent Background", | |
optional: true, | |
}, | |
const params = { | |
url: this.url, | |
viewport_width: this.width, | |
viewport_height: this.height, | |
format: this.format, | |
full_page: this.fullPage ? 1 : undefined, | |
wait_for_selector: this.waitForSelector, | |
omit_background: this.omitBackground ? 1 : undefined, | |
}; |
🤖 Prompt for AI Agents
In components/screenshotbase/actions/capture/capture.mjs around lines 42-51, the
declared action props waitForSelector and omitBackground are defined but not
passed to the Screenshotbase API; update the code that builds the API request
payload to include wait_for_selector (from waitForSelector) and omit_background
(from omitBackground) using the exact parameter names from the Screenshotbase
docs, ensuring optional props are only added when present and mapping camelCase
to snake_case.
test: { | ||
request: { | ||
url: "https://api.screenshotbase.com/status", | ||
headers: { | ||
apikey: "{{auth.api_key}}", | ||
}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test ignores custom base_url.
The test block hardcodes https://api.screenshotbase.com/status
even when the user provides a custom base_url
in the auth configuration. This will cause false negatives for users with custom base URLs, as the connection test will always validate against the default endpoint rather than their configured one.
Apply this diff to respect the user's base_url configuration:
test: {
request: {
- url: "https://api.screenshotbase.com/status",
+ url: "{{auth.base_url || 'https://api.screenshotbase.com'}}/status",
headers: {
apikey: "{{auth.api_key}}",
},
},
},
Note: If the test endpoint path differs between environments, you may need to adjust the template accordingly.
📝 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.
test: { | |
request: { | |
url: "https://api.screenshotbase.com/status", | |
headers: { | |
apikey: "{{auth.api_key}}", | |
}, | |
}, | |
}, | |
test: { | |
request: { | |
url: "{{auth.base_url || 'https://api.screenshotbase.com'}}/status", | |
headers: { | |
apikey: "{{auth.api_key}}", | |
}, | |
}, | |
}, |
🤖 Prompt for AI Agents
In components/screenshotbase/screenshotbase.app.mjs around lines 21 to 28, the
test request currently hardcodes the default status URL; change it to build the
URL from the user's configured base_url with a fallback to the default (e.g. use
auth.base_url if present otherwise https://api.screenshotbase.com, then append
the /status path, taking care to avoid double slashes), leaving the apikey
header intact so the connection test runs against the user's base_url when
provided.
Hello everyone, I have tested this PR and there're some test cases failed or needed improvement. Please check the test report below for more information |
test cases should be fixed now. |
@martechdev I still see the same error when publishing on my side ![]() |
Hello everyone, I have tested this PR and there're some test cases failed or needed improvement. Please check the test report below for more information |
Summary
Adds a new Screenshotbase integration with one app and four actions powered by the Take endpoint.
Website: https://screenshotbase.com
Docs: https://screenshotbase.com/docs/take
What’s included
screenshotbase
apikey
headerGET https://api.screenshotbase.com/status
GET /v1/take
)format=pdf
)format
,quality
,full_page
,viewport_width
,viewport_height
Files added
components/screenshotbase/screenshotbase.app.mjs
components/screenshotbase/actions/capture/capture.mjs
(Take Screenshot)components/screenshotbase/actions/take_pdf/take_pdf.mjs
(Take PDF)components/screenshotbase/actions/take_html/take_html.mjs
(Take from HTML)components/screenshotbase/actions/take_advanced/take_advanced.mjs
(Advanced)Endpoint usage (Take)
url
viewport_width
(default1280
)viewport_height
(default800
)full_page
(0
/1
)format
(jpg
,jpeg
,png
,gif
)quality
(forjpg
/jpeg
only)Testing instructions
url=https://example.com, viewport_width=1280, viewport_height=800, full_page=1, format=png
Example (Pipedream Code step):
Notes for reviewers
axios
from@pipedream/platform
and query params to match docs.apikey
header; app test uses/status
.Checklist
axios($)
and handles JSON responsesAttribution
Author: Everapi ([email protected])
Committer: martechdev
Summary by CodeRabbit