Skip to content

python-sdk: include "cancelled" in CrawlJob.status and exit wait loop on cancel (fixes #2190)#2240

Merged
rafaelsideguide merged 7 commits intofirecrawl:mainfrom
Jeelislive:bugs
Oct 1, 2025
Merged

python-sdk: include "cancelled" in CrawlJob.status and exit wait loop on cancel (fixes #2190)#2240
rafaelsideguide merged 7 commits intofirecrawl:mainfrom
Jeelislive:bugs

Conversation

@Jeelislive
Copy link
Copy Markdown
Contributor

@Jeelislive Jeelislive commented Oct 1, 2025

Summary:
- Add missing "cancelled" status to v2 CrawlJob and return immediately on cancellation in wait_for_crawl_completion().

Why:
- API can return status="cancelled", but SDK only allowed "scraping/completed/failed", causing Pydantic errors (see it Fixes
#2190 ).

Changes:
- apps/python-sdk/firecrawl/v2/types.py: CrawlJob.status → include "cancelled".
- apps/python-sdk/firecrawl/v2/methods/crawl.py: treat "cancelled" as terminal.

Tests:

- E2E verified locally (start → cancel → status = cancelled; waiter exits). Unit tests pass except a Python 3.8-only 
  asyncio.to_thread limitation (unrelated).

Backwards compatibility:
- Additive; no breaking changes.


Summary by cubic

Add “cancelled” support to CrawlJob and exit the wait loop when a crawl is cancelled. This fixes Pydantic validation errors and returns promptly on cancellation.

  • Bug Fixes
    • Include "cancelled" in CrawlJob.status to match API responses.
    • Treat "cancelled" as a terminal state in wait_for_crawl_completion().

@rafaelsideguide
Copy link
Copy Markdown
Collaborator

@cubic-dev-ai rerun

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Oct 1, 2025

@cubic-dev-ai rerun

@rafaelsideguide I've started the AI code review. It'll take a few minutes to complete.

@Jeelislive
Copy link
Copy Markdown
Contributor Author

Jeelislive commented Oct 1, 2025

@rafaelsideguide maybe you have to add this REDIS_RATE_LIMIT_URL in test-server

@rafaelsideguide
Copy link
Copy Markdown
Collaborator

@Jeelislive hmm could you pls remove the redis rate limit url from the workflow? I don't want to include that in this PR. Don't worry about the checks failing (they do very often unfortunately haha)

Copy link
Copy Markdown
Collaborator

@rafaelsideguide rafaelsideguide left a comment

Choose a reason for hiding this comment

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

pls remove the changes from workflows

@rafaelsideguide rafaelsideguide merged commit 57babba into firecrawl:main Oct 1, 2025
@rafaelsideguide
Copy link
Copy Markdown
Collaborator

Thanks, @Jeelislive! Merged. Really appreciate the effort here!

@cmin764
Copy link
Copy Markdown

cmin764 commented Oct 9, 2025

Great effort! Any idea when this will be released and under what version for firecrawl-py?

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.

3 participants