Skip to content

fix: narrow Wall velocity validation errors#1984

Open
benflexcompute wants to merge 2 commits intomainfrom
BenY/wall-velocity-validation-hotfix
Open

fix: narrow Wall velocity validation errors#1984
benflexcompute wants to merge 2 commits intomainfrom
BenY/wall-velocity-validation-hotfix

Conversation

@benflexcompute
Copy link
Copy Markdown
Collaborator

@benflexcompute benflexcompute commented Apr 10, 2026

Summary

  • fix WallRotation.angular_velocity so its field metadata is treated as a description instead of a default value
  • route Wall.velocity dict inputs through the tagged wall-velocity models before the tuple branch is attempted
  • add a regression test for missing WallRotation.angular_velocity

Why

Missing WallRotation.angular_velocity currently produces noisy validation output:

  • the field description string is parsed as a unit expression because it was accidentally used as the default value
  • Wall.velocity is a union with VelocityVectorType, so dict inputs also leak tuple/validator branch errors that are irrelevant once type_name already points to WallRotation

Validation

  • python -m py_compile flow360/component/simulation/models/surface_models.py tests/simulation/params/test_rotation.py
  • HOME=/tmp MPLCONFIGDIR=/tmp/matplotlib /disk2/ben/SchemaMigration/Flow360/.venv/bin/python3 -m pytest -c tests/pytest.ini -rA tests/simulation/params/test_rotation.py -k 'wall_angular_velocity or missing_angular_velocity'

Note

Medium Risk
Touches Pydantic validation for Wall.velocity unions, which can subtly change which branch is selected and the resulting error messages. Functional behavior should be unchanged for valid inputs, but invalid inputs will now fail differently and need test coverage (added here).

Overview
Improves WallRotation and Wall validation to produce cleaner, more relevant errors when parsing wall velocity inputs.

Fixes WallRotation.angular_velocity field metadata so the description is no longer treated as a default value, and adds a Wall.velocity pre-validator that routes dict inputs with type_name through a TypeAdapter for the tagged wall-velocity models (avoiding noisy tuple-branch errors from VelocityVectorType). Adds a regression test asserting a missing angular_velocity reports a single Field required error without irrelevant union/tuple noise.

Reviewed by Cursor Bugbot for commit 27628c6. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

2 participants