Skip to content

Conversation

@ntindle
Copy link
Member

@ntindle ntindle commented Nov 26, 2025

Summary

  • Clamp start_time to at least 10 seconds before request time (Twitter API requirement)
  • Update input description to document this automatic adjustment
  • Fix serialize_list to handle None data gracefully (exposed by the fix)

Background

Twitter API returns 400 Bad Request when start_time is less than 10 seconds before the request time. Users providing current/future times would hit this error.

Sentry Issue: BUILDER-3PG

Affected Blocks

  • TwitterSearchRecentTweetsBlock
  • TwitterGetUserMentionsBlock
  • TwitterGetHomeTimelineBlock
  • TwitterGetUserTweetsBlock

Test plan

  • Tested TwitterSearchRecentTweetsBlock with current time as start_time
  • Verified clamping works and API call succeeds
  • Verified "No tweets found" is returned correctly when search window has no results

🤖 Generated with Claude Code

Twitter API requires start_time to be at least 10 seconds prior to the
request time. When users provide a future time or a time too close to now,
the API returns a 400 error.

Changes:
- Clamp start_time to max(start_time, now - 10s) in TweetDurationBuilder
- Update input description to document this behavior
- Fix serialize_list to handle None data gracefully

Affected blocks:
- TwitterSearchRecentTweetsBlock
- TwitterGetUserMentionsBlock
- TwitterGetHomeTimelineBlock
- TwitterGetUserTweetsBlock

Fixes BUILDER-3PG

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@ntindle ntindle requested a review from a team as a code owner November 26, 2025 18:31
@ntindle ntindle requested review from Pwuts and kcze and removed request for a team November 26, 2025 18:31
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Nov 26, 2025
@netlify
Copy link

netlify bot commented Nov 26, 2025

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit 98fe507
🔍 Latest deploy log https://app.netlify.com/projects/auto-gpt-docs-dev/deploys/6929273b2f62e000085ed002

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/twitter-start-time-validation

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link

netlify bot commented Nov 26, 2025

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 98fe507
🔍 Latest deploy log https://app.netlify.com/projects/auto-gpt-docs/deploys/6929273beb12cb00087c09b1

@qodo-merge-pro
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Timezone Handling

When clamping, naive datetimes are force-set to UTC via replace(), which assumes naive input is UTC. Confirm this assumption or consider converting via application default timezone to avoid silent time shifts.

if start_time.tzinfo is None:
    start_time = start_time.replace(tzinfo=timezone.utc)
if start_time > max_start_time:
    start_time = max_start_time
self.params["start_time"] = start_time
Start Time Serialization

Ensure the clamped datetime is serialized to the exact RFC3339/ISO8601 format the Twitter API expects (e.g., with 'Z'); if downstream serialization isn't guaranteed, add explicit formatting to prevent 400s due to formatting.

def add_start_time(self, start_time: datetime | None):
    if start_time:
        # Twitter API requires start_time to be at least 10 seconds before now
        max_start_time = datetime.now(timezone.utc) - timedelta(seconds=10)
        if start_time.tzinfo is None:
            start_time = start_time.replace(tzinfo=timezone.utc)
        if start_time > max_start_time:
            start_time = max_start_time
        self.params["start_time"] = start_time
    return self
None vs Empty List Semantics

serialize_list now returns [] for None; verify callers do not rely on distinguishing None from an empty payload for conditional logic or pagination, as this may change behavior.

def serialize_list(cls, data: List[Dict[str, Any]] | None) -> List[Dict[str, Any]]:
    """Serializes a list of dictionary items"""
    if not data:
        return []
    return [cls.serialize_dict(item) for item in data]

@deepsource-io
Copy link

deepsource-io bot commented Nov 26, 2025

Here's the code health analysis summary for commits 3d08c22..98fe507. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗
DeepSource Python LogoPython✅ Success
❗ 1 occurence introduced
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@ntindle ntindle requested a review from Abhi1992002 November 26, 2025 18:32
Copy link
Contributor

@Abhi1992002 Abhi1992002 left a comment

Choose a reason for hiding this comment

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

lgtm

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 👍🏼 Mergeable

Development

Successfully merging this pull request may close these issues.

3 participants