fix: resolve UnsupportedFieldAttributeWarning for secret_registry field #1625
+9
−3
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.
Summary
This PR fixes the
UnsupportedFieldAttributeWarningerrors appearing in production logs for thesecret_registryfield inConversationState.Problem
The following warnings were appearing in Datadog logs in production:
These warnings occur because
ConversationStateinherits fromOpenHandsModel, which is involved in discriminated union serialization. In Pydantic 2.x,validation_alias,serialization_alias, andfrozenattributes when used directly inField()don't work correctly in union type contexts. The warning explicitly states these are "field-specific metadata, and can only be attached to a model field usingAnnotatedmetadata or by assignment."Root Cause
This was introduced in c6ebf3d (PR #969) when adding alias support for backward compatibility with
secrets_managerfield name.Solution
validation_aliasandserialization_aliasfrom theField()definitionmodel_validator(mode='before')to handle the legacysecrets_managerkey for backward compatibilityserialization_aliaswas redundant anyway since it matched the field nameTesting
ConversationStatesecrets_managerkey is still correctly mapped tosecret_registrytests/sdk/conversation/test_conversation_secrets_constructor.py✅tests/sdk/conversation/test_secrets_manager.py✅@neubig can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:612cb8c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
612cb8c-python) is a multi-arch manifest supporting both amd64 and arm64612cb8c-python-amd64) are also available if needed