Skip to content

feat(sqlalchemy): validate UUID input fields#1168

Draft
aiolibsbot wants to merge 1 commit into
aio-libs:masterfrom
aiolibsbot:koan/uuid-input-validation
Draft

feat(sqlalchemy): validate UUID input fields#1168
aiolibsbot wants to merge 1 commit into
aio-libs:masterfrom
aiolibsbot:koan/uuid-input-validation

Conversation

@aiolibsbot

@aiolibsbot aiolibsbot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What: UUID columns now emit a regex validator so admin create/edit forms reject malformed UUIDs client-side.

Why: sa.Uuid mapped to a plain TextInput with no validation (the # TODO: validators on the mapping). Any string was accepted in the form and only rejected server-side by Pydantic — a worse UX than the surrounding validated inputs. Part of #666 (TODO cleanup).

How: Added a canonical-form UUID pattern (8-4-4-4-12 hex, matching str(uuid.UUID(...))) and appended a regex validator for sa.Uuid columns in _get_validators. The frontend already deserializes regexp validator state into a RegExp, so no admin-js change is needed. Server-side Pydantic validation is unchanged and remains authoritative.

Testing: New test_uuid_validator asserts the emitted validator. Full suite: 98 passed, 1 xfailed; the lone test_admin_view failure is pre-existing (#934) and unrelated.


Quality Report

Changes: 2 files changed, 22 insertions(+), 1 deletion(-)

Code scan: clean

Tests: failed (command not found)

Branch hygiene: clean

Generated by Kōan

UUID columns rendered as TextInput accepted any string on the client.
Emit a canonical-form regex validator so malformed UUIDs are caught in
the create/edit forms before submission. Completes the 'validators' TODO
on the sa.Uuid mapping (part of aio-libs#666).

The frontend already deserializes regexp validator state, so no admin-js
change is needed.
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.65%. Comparing base (2448fd1) to head (4f4c2d2).
⚠️ Report is 168 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1168      +/-   ##
==========================================
+ Coverage   95.56%   95.65%   +0.08%     
==========================================
  Files          21       21              
  Lines        2954     2966      +12     
  Branches      193      201       +8     
==========================================
+ Hits         2823     2837      +14     
+ Misses        105      103       -2     
  Partials       26       26              
Flag Coverage Δ
integration 80.92% <33.33%> (-0.03%) ⬇️
js 83.89% <ø> (ø)
unit 97.51% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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