Repository navigation
fix: reject values the columns cannot store with a 422 - #2695
Merged
Merged
Conversation
An outing with a height difference of 35000 m failed with a 500
("smallint out of range"). The integer fields now have the range of
their column (SmallInt for smallint columns, Int for integer ones),
answered with pydantic's error types (less_than_equal and
greater_than_equal, with the limit in ctx) so the UI can translate them.
Also bounded: the update message (history_metadata.comment is a
varchar(200)), the registration email (varchar(200)), and the SSO sync
fields (external_id is an integer column, email/username/name are
varchar(200)).
A test checks every field of the model schemas against its column.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 30 |
| Duplication | -2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forum topic 371560: a multi-week trek with
height_diff_up35000 could not be saved.height_diff_upis asmallintcolumn, PostgreSQL refused the value, and the API answered a 500 ("unexpected error, please consult the server logs").The schemas now refuse any value their column cannot store with a 422 naming the field:
SmallInt(±32767) for everysmallintcolumn (books, images, outings, routes, waypoints, xreports);Intis bounded to int32.Errors use the FastAPI format:
less_than_equal/greater_than_equalwithctx.le/ctx.ge.Str(n)lengths forvarchar(n)columns that had none: the update message (history_metadata.comment, 200), the registration email (200), and the SSO email, username and name (200).OneOfgets the length of its longest choice.external_idis anInt.forum_usernamekeeps its own check (validate_forum_username, a 400 as before).tests/schemas/test_storage_limits.pywalks everyModelSchemaand checks each integer andString(n)field against its column, so a new field without a bound fails the tests. That test is how the registration email gap was found.The DB column stays
smallint: a trek over 32 km of height difference is rare enough to stay an exception. The UI side is c2corg/c2c_ui#5226.🤖 Generated with Claude Code