Cloud-Code-AI / kaizen

Automate the tedious development tasks with AI
https://cloudcode.ai/kaizen/docs/
MIT License
273 stars 35 forks source link

Input Validation for API URL #636

Closed Kaos599 closed 6 days ago

Kaos599 commented 6 days ago

Enhance PR Input Validation with Pydantic

✨ Generated with love by Kaizen ❤️

Original Description - Introduced pydantic model `PRRequestModel` to validate `owner`, `repo`, and `pr_number` inputs before constructing GitHub API URLs - Enforced input rules: - `owner` should match GitHub username conventions (1-39 alphanumeric characters) - `repo` should follow GitHub repo naming conventions (1-100 characters, allowing '.', '_', '-') - `pr_number` should be a positive integer - Updated `get_pr_info` and `get_pr_files` functions to use validated inputs, ensuring only compliant values are used in API requests - Added error handling in `main` function to catch `ValidationError` and provide clear feedback on invalid inputs
kaizen-bot[bot] commented 6 days ago

🔍 Code Review Summary

Attention Required: This push has potential issues. 🚨

Overview

performance (1 issues)
_ 1. Repeated validation of inputs in multiple functions._ ------ 📁 **File:** [kaizen/tests/actions/diff_pr_test.py](kaizen/tests/actions/diff_pr_test.py#L15) 🔍 **Reasoning:** Validating inputs in multiple functions can lead to redundant code and performance overhead. 💡 **Solution:** Consider creating a wrapper function that validates inputs once and returns validated data for reuse. **Current Code:** ```python validated_data = PRRequestModel(owner=owner, repo=repo, pr_number=pr_number) ``` **Suggested Code:** ```python def validate_pr_request(owner, repo, pr_number): return PRRequestModel(owner=owner, repo=repo, pr_number=pr_number) validated_data = validate_pr_request(owner, repo, pr_number) ```

Test Cases 3 file need updates to their tests. Run `!unittest` to generate create and update tests.

✨ Generated with love by Kaizen ❤️

Useful Commands - **Feedback:** Share feedback on kaizens performance with `!feedback [your message]` - **Ask PR:** Reply with `!ask-pr [your question]` - **Review:** Reply with `!review` - **Update Tests:** Reply with `!unittest` to create a PR with test changes