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 #637

Closed Kaos599 closed 1 day ago

Kaos599 commented 6 days ago

Validate PR Request Inputs

✨ Generated with love by Kaizen ❤️

Original Description # Enhance PR Input Validation - ****Purpose:** ** Improve input validation for pull request data using Pydantic. - ****Key Changes:**** - Introduced `PRRequestModel` for structured input validation. - Added `validate_pr_request` function to encapsulate validation logic. - Updated `get_pr_info` and `get_pr_files` functions to use validated data. - Added error handling for validation errors with clear output. - ****Impact:** ** Increases robustness of the code by ensuring valid inputs before making API calls. > ✨ Generated with love by [Kaizen](https://cloudcode.ai) ❤️
Original Description # Enhance PR Input Validation - ******Purpose:** ** ** Improve input validation for pull request data using Pydantic. - ******Key Changes:****** - Introduced `PRRequestModel` for structured input validation. - Added `validate_pr_request` function to encapsulate validation logic. - Updated `get_pr_info` and `get_pr_files` to utilize validated data. - Enhanced error handling for input validation with `ValidationError`. - ******Impact:** ** ** Increases robustness of the code by ensuring valid input before making API calls. > ✨ Generated with love by [Kaizen](https://cloudcode.ai) ❤️
Original Description # Validate PR Request Inputs - ********Purpose:** ** ** ** Improve input validation for GitHub PR requests. - ********Key Changes:******** - Added a Pydantic model `PRRequestModel` to validate the `owner`, `repo`, and `pr_number` inputs. - Implemented a `validate_pr_request` wrapper function to validate the inputs before making the API calls. - Updated the `get_pr_info` and `get_pr_files` functions to use the validated inputs. - ********Impact:** ** ** ** This change ensures that the input parameters for the GitHub PR requests are properly validated, reducing the risk of errors and improving the overall robustness of the code. > ✨ Generated with love by [Kaizen](https://cloudcode.ai) ❤️
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 - Improved security by sanitizing inputs, mitigating the risk of URL manipulation leading to API abuse and unauthorized access
sauravpanda commented 5 days ago

@Kaos599 can you fix the linting issues, we use black and flake8

Kaos599 commented 5 days ago

@sauravpanda I have made changes that should resolve all flake8 linting issues (E302, E305, and F722).

Before merging also assign this PR with the hacktoberfest label. Thank you

kaizen-bot[bot] commented 4 days ago

🔍 Code Review Summary

All Clear: This commit looks good! 👍

Overview

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
Kaos599 commented 4 days ago

@sauravpanda. Sorry for the previous issue. I have revised the code to fit Flake8 and Black's Compliance.