Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(go-sdk): add client-side validation for negative limit values

Devin AIe77b4f4243e0
diff --git a/apps/go-sdk/firecrawl.go b/apps/go-sdk/firecrawl.go
index 03f72c4ab..33f0361f7 100644
--- a/apps/go-sdk/firecrawl.go
+++ b/apps/go-sdk/firecrawl.go
@@ -170,6 +170,9 @@ func (c *Client) StartCrawl(ctx context.Context, url string, opts *CrawlOptions)
if url == "" {
return nil, &FirecrawlError{Message: "URL is required"}
}
+ if opts != nil && opts.Limit != nil && *opts.Limit <= 0 {
+ return nil, &FirecrawlError{Message: "limit must be positive"}
+ }
body := map[string]interface{}{"url": url}
mergeOptions(body, opts)
@@ -361,6 +364,9 @@ func (c *Client) Map(ctx context.Context, url string, opts *MapOptions) (*MapDat
if url == "" {
return nil, &FirecrawlError{Message: "URL is required"}
}
+ if opts != nil && opts.Limit != nil && *opts.Limit <= 0 {
+ return nil, &FirecrawlError{Message: "limit must be positive"}
+ }
body := map[string]interface{}{"url": url}
mergeOptions(body, opts)
@@ -386,6 +392,9 @@ func (c *Client) Search(ctx context.Context, query string, opts *SearchOptions)
if query == "" {
return nil, &FirecrawlError{Message: "query is required"}
}
+ if opts != nil && opts.Limit != nil && *opts.Limit <= 0 {
+ return nil, &FirecrawlError{Message: "limit must be positive"}
+ }
body := map[string]interface{}{"query": query}
mergeOptions(body, opts)