Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

Summary

  • Fixed GitHub discussions search by using GraphQL API instead of non-existent REST endpoint
  • Fixed turbopuffer authentication by setting API key via environment variable
  • Refactored GitHub functionality into clean module structure

Changes

🐛 Bug Fixes

  • GitHub Discussions Search: Now uses GraphQL search field with type: DISCUSSION (REST endpoint /search/discussions doesn't exist)
  • Turbopuffer Auth: Sets TURBOPUFFER_API_KEY environment variable from Prefect secret in settings validator
  • Model Handling: Fixed format_discussions_summary to handle GitHubUser Pydantic models instead of dicts
  • Error Handling: Errors now return helpful messages instead of leaking stack traces to Slack

🏗️ Refactoring

  • Organized GitHub functionality into module with clear separation:
    • client.py - Centralized GitHub API client with auth
    • models.py - Pydantic models for GitHub entities
    • exceptions.py - Custom exception hierarchy
    • issues.py - Issue search functionality
    • discussions.py - Discussion search and creation
  • Removed duplicate code from search.py

⚡ Performance

  • Skip Prefect task wrapping for internal pydantic-ai tools like final_result
  • Prevent repeated tool calls with improved docstrings

Test Plan

  • Tested GitHub discussions search locally
  • Verified turbopuffer doc search works
  • Confirmed error handling returns user-friendly messages
  • Deploy to dev environment for final verification
  • Monitor logs for any issues before promoting to prod

🤖 Generated with Claude Code

- Refactor GitHub functionality into organized module structure
- Fix turbopuffer API key authentication via environment variable
- Use GraphQL API for GitHub discussions search (REST endpoint doesn't exist)
- Fix GitHubUser model handling in format_discussions_summary
- Improve error handling to prevent stack traces leaking to Slack
- Skip Prefect task wrapping for internal pydantic-ai tools
- Add admin notifications for discussion creation

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

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings August 13, 2025 03:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes critical bugs in the slackbot's GitHub integration and improves error handling. The main issues addressed are fixing GitHub discussions search (which was using a non-existent REST endpoint) and turbopuffer authentication setup.

Key changes:

  • Fixed GitHub discussions search by implementing GraphQL API instead of non-existent REST endpoint
  • Added automatic turbopuffer API key configuration through Prefect secrets
  • Refactored GitHub functionality into a clean modular structure with proper error handling

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
examples/slackbot/src/slackbot/wrap.py Skip Prefect wrapping for internal pydantic-ai tools to prevent unnecessary overhead
examples/slackbot/src/slackbot/settings.py Add turbopuffer API key auto-configuration and admin notification settings
examples/slackbot/src/slackbot/search.py Remove duplicate GitHub code and turbopuffer auth, delegate to new GitHub module
examples/slackbot/src/slackbot/github/models.py Define Pydantic models for GitHub entities (users, issues, discussions, etc.)
examples/slackbot/src/slackbot/github/issues.py Implement GitHub issues search functionality with proper error handling
examples/slackbot/src/slackbot/github/exceptions.py Define custom exception hierarchy for GitHub API errors
examples/slackbot/src/slackbot/github/discussions.py Implement GitHub discussions search using GraphQL and discussion creation
examples/slackbot/src/slackbot/github/client.py Centralized GitHub API client with authentication and error handling
examples/slackbot/src/slackbot/github/init.py Module exports for GitHub functionality
examples/slackbot/src/slackbot/github.py Remove old GitHub code (replaced by new modular structure)
examples/slackbot/src/slackbot/core.py Add GitHub discussions tools and comprehensive error handling
examples/slackbot/src/slackbot/api.py Add top-level error handling for agent execution

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Define named constants for body truncation lengths (BODY_TRUNCATE_LENGTH, BODY_DISPLAY_LENGTH)
- Replace magic numbers with named constants for better maintainability
@zzstoatzz zzstoatzz merged commit c52ff20 into main Aug 13, 2025
3 checks passed
@zzstoatzz zzstoatzz deleted the fix-slackbot-github-discussions branch August 13, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants