conflict issues#6
Conversation
…e validation (#5) * Remove issue markdown file and provide issue text inline * Modularize stability computation with isolated service logic * Add detailed backend feature and architecture docs * Fix stability request length validation after cleaning
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 405956141c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def validate_amino_acids(cls, v: str) -> str: | ||
| """Strip whitespace/digits, uppercase, then reject invalid amino-acid letters.""" | ||
| cleaned = re.sub(r"[\s\d]", "", v).upper() | ||
| invalid = set(cleaned) - VALID_AMINO_ACIDS | ||
| if invalid: | ||
| raise ValueError( | ||
| f"Sequence contains invalid characters: {', '.join(sorted(invalid))}. " | ||
| f"Only standard amino-acid letters are allowed: {''.join(sorted(VALID_AMINO_ACIDS))}" | ||
| ) | ||
| return cleaned |
There was a problem hiding this comment.
Validate solubility sequence length after cleanup
SolubilityRequest strips whitespace and digits in the validator, but it never re-checks the cleaned length. That means /api/solubility will happily accept inputs like "1 2 3 4 5 6 7 8 9 0" and return a 0-residue score, and it will also reject numbered/wrapped sequences based on the raw string length before cleanup. PredictRequest and StabilityRequest both enforce the post-clean 10-2000 residue constraint, so this endpoint now returns meaningless results for malformed payloads that the other sequence endpoints correctly reject.
Useful? React with 👍 / 👎.
| if min_score < 0 or min_score > 100 or max_score < 0 or max_score > 100: | ||
| raise HTTPException(status_code=400, detail="Scores must be between 0 and 100") | ||
|
|
||
| if min_score > max_score: | ||
| raise HTTPException(status_code=400, detail="min_score must be less than or equal to max_score") |
There was a problem hiding this comment.
Reject NaN score filters before returning search results
If a client sends min_score=NaN or max_score=NaN, all of these range checks evaluate false, so the handler falls through and returns a payload containing nan. FastAPI/Starlette's default JSON response does not serialize NaN values, so this turns an invalid query into a 500 instead of a 4xx. Guarding with math.isfinite() (or constrained query params) would keep the endpoint from crashing on that input.
Useful? React with 👍 / 👎.
No description provided.