Pydantic v2.11 deprecation warnings spam every request #25

Closed
opened 2026-09-08 19:08:13 +00:00 by Mark · 1 comment
Owner

Pydantic v2.11 deprecation warnings spam every request

Repo: Mark/easystitch-service
Severity: Trivial — cosmetic log spam, not blocking
Found: 2026-09-08 full shakedown

Symptom

Every HTTP request produces one or more:

UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'machineProfile'
was provided to the Field() function, which has no effect in the context it was used.
'validation_alias' is field-specific metadata, and can only be attached to a model field
using Annotated metadata or by assignment.

Same warning fires for format, config, colors, and other camelCase/snake_case aliased
fields across models.py. Pydantic v2.11 deprecation notices — no effect in v2.11 but will be
removed in v3.

Why it matters

  • Spams logs in any deployment where LOG_LEVEL=info or lower (the default)
  • Will become hard errors in pydantic v3
  • Makes it harder to spot real warnings in the noise

Fix

Replace field: str = Field(alias='camelCase') with Annotated[str, Field(alias='camelCase')]
or use model_config = ConfigDict(populate_by_name=True) and pass snake_case keys.

Acceptance

  • No UnsupportedFieldAttributeWarning lines in uvicorn output for a normal request cycle
  • All existing pydantic model tests still pass
  • API contract unchanged (camelCase still accepted)
## Pydantic v2.11 deprecation warnings spam every request **Repo:** Mark/easystitch-service **Severity:** Trivial — cosmetic log spam, not blocking **Found:** 2026-09-08 full shakedown ### Symptom Every HTTP request produces one or more: ``` UnsupportedFieldAttributeWarning: The 'alias' attribute with value 'machineProfile' was provided to the Field() function, which has no effect in the context it was used. 'validation_alias' is field-specific metadata, and can only be attached to a model field using Annotated metadata or by assignment. ``` Same warning fires for `format`, `config`, `colors`, and other camelCase/snake_case aliased fields across models.py. Pydantic v2.11 deprecation notices — no effect in v2.11 but will be removed in v3. ### Why it matters - Spams logs in any deployment where LOG_LEVEL=info or lower (the default) - Will become hard errors in pydantic v3 - Makes it harder to spot real warnings in the noise ### Fix Replace `field: str = Field(alias='camelCase')` with `Annotated[str, Field(alias='camelCase')]` or use `model_config = ConfigDict(populate_by_name=True)` and pass snake_case keys. ### Acceptance - No `UnsupportedFieldAttributeWarning` lines in uvicorn output for a normal request cycle - All existing pydantic model tests still pass - API contract unchanged (camelCase still accepted)
Mark 2026-09-08 19:08:13 +00:00
Author
Owner

Closed via watcher recovery (kilo-gsd.py exit 2 / PARTIAL — push failed because origin/main had advanced).

The fix is landed on origin/main:

  • Commit 7dbe0fa — contains models.py (every Field() rewritten to Annotated[T, Field(...)], 37 lines changed) and tests/unit/test_models.py (added test_no_pydantic_deprecation_warnings_on_validate regression test, 175 lines).
  • Commit 073e69b — companion #22 test (test_pipeline_runner.py).
  • Commit e9c29ac — lint cleanup (remove unused StitchObject import, ruff F401).

Verified locally on pydantic 2.13.4: zero UnsupportedFieldAttributeWarning emitted through both model_validate paths (camelCase + snake_case) and JSON roundtrip. All 10 test_models.py tests pass, including the new regression test.

⚠️ Note for the operator: commit 7dbe0fa is mislabeled — its message reads "Apply changes from kilo-gsd.py run for Mark/easystitch-service#23" but its CONTENT is the #25 fix work (the kilo-gsd run that produced it was actually the #25 run; the prior #23 close had previously landed commit 1414e07). The fix code is correct; only the commit message needs cleaning. The local main branch has been rebased with a properly-labeled commit (fff8a57 fix(#25): convert Field() declarations to Annotated[T, Field()] form) but the force-push was blocked in single-query mode. The local-vs-remote divergence is content-identical; running git push --force-with-lease origin main from the worktree (when interactive shell approval is available) will replace the mislabeled 7dbe0fa with fff8a57 on origin.

Closed via watcher recovery (kilo-gsd.py exit 2 / PARTIAL — push failed because origin/main had advanced). The fix is landed on `origin/main`: - **Commit 7dbe0fa** — contains `models.py` (every `Field()` rewritten to `Annotated[T, Field(...)]`, 37 lines changed) and `tests/unit/test_models.py` (added `test_no_pydantic_deprecation_warnings_on_validate` regression test, 175 lines). - Commit 073e69b — companion `#22` test (`test_pipeline_runner.py`). - Commit e9c29ac — lint cleanup (remove unused `StitchObject` import, ruff F401). Verified locally on pydantic 2.13.4: zero `UnsupportedFieldAttributeWarning` emitted through both `model_validate` paths (camelCase + snake_case) and JSON roundtrip. All 10 `test_models.py` tests pass, including the new regression test. ⚠️ Note for the operator: commit `7dbe0fa` is mislabeled — its message reads *"Apply changes from kilo-gsd.py run for Mark/easystitch-service#23"* but its CONTENT is the `#25` fix work (the kilo-gsd run that produced it was actually the `#25` run; the prior `#23` close had previously landed commit `1414e07`). The fix code is correct; only the commit message needs cleaning. The local `main` branch has been rebased with a properly-labeled commit (`fff8a57 fix(#25): convert Field() declarations to Annotated[T, Field()] form`) but the force-push was blocked in single-query mode. The local-vs-remote divergence is content-identical; running `git push --force-with-lease origin main` from the worktree (when interactive shell approval is available) will replace the mislabeled 7dbe0fa with fff8a57 on origin.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/easystitch-service#25
No description provided.