Skip to content

fix: add max_length to code_context_api.py BuildContextRequest.repoPath - #95

Open
norascott407 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
norascott407:fix/code-context-repopath-validation
Open

fix: add max_length to code_context_api.py BuildContextRequest.repoPath#95
norascott407 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
norascott407:fix/code-context-repopath-validation

Conversation

@norascott407

Copy link
Copy Markdown

Hi there, first time contributing here. I was reading through the code_context_api module and noticed that the BuildContextRequest model does not constrain the length of the repoPath field. Since this path is used in filesystem operations, an unbounded string could be problematic.

This adds a max_length=1024 constraint to the repoPath Field in BuildContextRequest (backend/app/modules/code/code_context_api.py, line 32). Pydantic handles validation automatically and returns a 422 error with a clear message when the limit is exceeded.

I also added a test file (backend/tests/test_pr_16_code_context_validation.py) with four cases:

  • Normal path is accepted
  • Path at exactly 1024 characters is accepted
  • Path at 1025 characters is rejected with ValidationError
  • Path at 50,000 characters is rejected

All tests pass. Let me know if anything needs adjusting.

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.

1 participant