Skip to content

Issue #1467: fix: move DeveloperApiKeyDTO to pydantic v2 ConfigDict - #1473

Merged
bjagg merged 1 commit into
mainfrom
issue-1467-dto-config
Nov 4, 2026
Merged

bjagg merged 1 commit into
mainfrom
issue-1467-dto-config

Conversation

@dereck-symmetry

Copy link
Copy Markdown
Contributor
Description of Change

Problem. DeveloperApiKeyDTO (components/lif/developer_keys/dto.py) configured itself with a pydantic v1-style inner class:

class Config:
    orm_mode = True
    from_attributes = True

On pydantic 2.11.6, importing the module raises UserWarning: 'orm_mode' has been renamed to 'from_attributes'. That warning shows up in every test run and service start that imports the brick. bjagg flagged it in his read of #1466.

Solution. The inner class is now model_config = ConfigDict(from_attributes=True). from_attributes was already True, and v2 ignores orm_mode apart from the warning, so behavior doesn't change.

Blast radius. developer_keys is a shared brick, packaged by:

Limitations. The same orm_mode warning still comes from components/lif/mdr_dto/ (24 places), so the MDR test runs still show it. That's out of scope per #1467.

How to test.

  • uv run pytest test/components/lif/developer_keys/test_dto.py
  • uv run python -W error::UserWarning -c "import lif.developer_keys.dto" exits 0. On main it fails with the orm_mode warning.
Related Issues

Closes #1467
Refs #1466

Type of Change
  • Bug fix (non-breaking change which fixes an issue)
Project Area(s) Affected
  • components/
  • test/ or e2e/

Checklist
  • commit message follows commit guidelines (see commitlint.config.mjs)
  • tests are included (unit and/or integration tests)
  • code passes linting checks (uv run ruff check)
  • code passes formatting checks (uv run ruff format)
  • code passes type checking (uv run ty check)
  • pre-commit hooks have been run successfully
Testing
  • Automated tests added/updated

New file: test/components/lif/developer_keys/test_dto.py.

  • test_dto_module_imports_without_a_config_warning imports the module in a fresh interpreter with -W error::UserWarning. It failed before the fix with the orm_mode warning (confirmed directly, not an import error) and passes after.
  • test_dto_validates_from_an_orm_row checks that model_validate still builds the DTO from an attribute object, the way both key listings do. It needs no database, so it runs everywhere.

The existing key tests pass against a real PostgreSQL, 51 passed with none skipped, run in the local pgtest container across:

  • test/components/lif/developer_keys/
  • test/bases/lif/mdr_restapi/test_developer_api_key_{endpoints,service}.py
  • test/bases/lif/control_plane_restapi/

Without PostgreSQL, 10 of those skip. pre-commit on the changed files is green.

Additional Notes

The diff doesn't share files with any open PR. #1464 only adds .github/workflows/lif_control_plane_api.yml.

🤖 Generated with Claude Code

Replace the v1-style inner `class Config` (orm_mode + from_attributes)
with `model_config = ConfigDict(from_attributes=True)`. from_attributes
was already on and v2 ignores orm_mode, so behavior is unchanged; the
import-time UserWarning goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@bjagg bjagg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 0272ef9.

  • from_attributes was already on, so moving to ConfigDict doesn't change behavior. Only the warning goes.
  • The tests pass locally (2 passed). With main's dto.py restored, the import-warning test fails and the ORM-row test still passes, as it should.
  • CI is green on 0272ef9.

Thanks for the quick turnaround.

@bjagg
bjagg merged commit 6a8dcfa into main Nov 4, 2026
4 checks passed
@bjagg
bjagg deleted the issue-1467-dto-config branch November 4, 2026 23:14
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Current Community Efforts Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

developer_keys: move DeveloperApiKeyDTO off the deprecated class Config: orm_mode

2 participants