wooden-umbrella-84098
11/19/2025, 2:14 PM[11/19/25 14:13:58] ERROR HTTP request failed (422 Unprocessable Entity): remote_conversation.py:61
{'detail': [{'type': 'union_tag_invalid', 'loc': ['body',
'secrets', 'GITHUB_TOKEN'], 'msg': "Input tag 'str' found
using kind_of() does not match any of the expected tags:
'LookupSecret', 'StaticSecret'", 'input':
'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', 'ctx':
{'discriminator': 'kind_of()', 'tag': 'str',
'expected_tags': "'LookupSecret', 'StaticSecret'"}}]}chilly-france-44439
11/19/2025, 3:31 PMStaticSecret, this feels like a bug to me. Is that correct? @straight-sundown-84319straight-sundown-84319
11/19/2025, 6:48 PMchilly-france-44439
11/19/2025, 6:48 PMwooden-umbrella-84098
11/19/2025, 7:26 PMwooden-umbrella-84098
11/19/2025, 7:26 PMwooden-umbrella-84098
11/19/2025, 7:26 PMnutritious-balloon-65098
11/19/2025, 7:27 PMnutritious-balloon-65098
11/19/2025, 7:37 PMRemoteConversation.update_secrets() method was sending plain strings to the server, but the server expected StaticSecret objects with a discriminated union format, causing a 422 Unprocessable Entity error.
Solution: Modified the method to automatically convert strings to StaticSecret objects using the existing _wrap_secret() helper and proper serialization. The fix ensures:
⢠Strings are automatically converted to StaticSecret format: {"kind": "StaticSecret", "value": "secret-value"}
⢠Both string and callable secrets work correctly
⢠Backward compatibility is maintained
Changes Made:
1. Core Fix: Updated RemoteConversation.update_secrets() in remote_conversation.py
2. Enhanced Tests: Added comprehensive payload format verification in test_remote_conversation.py
Verification: All tests pass, pre-commit checks pass, and manual verification confirms the fix works correctly.
The changes have been committed locally. Would you like me to push these changes to a new branch and create a pull request, or would you prefer a different Git workflow?
<sub>View full conversation</sub>wooden-umbrella-84098
11/22/2025, 4:40 PMwooden-umbrella-84098
11/22/2025, 4:41 PMnutritious-balloon-65098
11/22/2025, 4:45 PMRemoteConversation.update_secrets() to automatically convert strings to StaticSecret objects
3. ā
Automatic conversion: Implemented using existing _wrap_secret() helper function
4. ā
Enhanced testing: Added comprehensive test assertions to verify payload format
5. ā
Pushed to GitHub: Created PR #1231 with detailed description
š§ Changes Made (Concise & Focused)
Git diff shows exactly 2 files modified:
⢠remote_conversation.py: Fixed update_secrets() method (13 lines changed)
⦠Added import for _wrap_secret
⦠Modified method to wrap secrets in StaticSecret objects before sending to server
⢠test_remote_conversation.py: Enhanced existing tests (48 lines added)
⦠Added payload format verification for both string and callable secrets
⦠Verified StaticSecret object structure matches server expectations
Total: 61 lines changed across 2 files - all changes directly address the reported bug.
š Work Already Completed & Pushed
Pull Request: https://github.com/OpenHands/software-agent-sdk/pull/1231
⢠ā
Changes pushed to fix-secrets-staticSecret-conversion branch
⢠ā
Draft PR created with comprehensive description
⢠ā
All tests passing (17/17 remote conversation tests)
⢠ā
Pre-commit hooks passed
š” Server-Side Enhancement Opportunity
Answer to your question: Yes, there could be a complementary server-side fix that would make the API more user-friendly by accepting both plain strings AND StaticSecret objects. The server could use a Pydantic @field_validator to automatically wrap plain strings in StaticSecret objects, eliminating the need for client-side conversion entirely.
Current Status: The immediate bug is fixed with the client-side solution. A server-side enhancement would be a nice future improvement for better developer experience.
<sub>View full conversation</sub>nutritious-balloon-65098
11/22/2025, 4:55 PMopenhands-agent-server/openhands/agent_server/models.py
⢠Added convert_string_secrets field validator to UpdateSecretsRequest.secrets
⢠Automatically converts plain strings to StaticSecret(value=SecretStr(string_value))
⢠Handles multiple input formats while preserving existing functionality
š§Ŗ Testing Coverage
Files: tests/agent_server/test_models.py + tests/agent_server/test_conversation_router.py
⢠7 unit tests for model validation (string conversion, mixed formats, edge cases)
⢠2 integration tests for API endpoint functionality
⢠All tests passing ā
š Pull Request Created
PR #1232: https://github.com/OpenHands/software-agent-sdk/pull/1232
⢠Status: Draft (ready for review)
⢠Branch: server-side-secrets-fix
⢠Changes: Server-side automatic string secret conversion
⢠Backward Compatible: Existing clients continue working unchanged
šÆ Problem Solved
The original 422 validation error when sending plain string secrets is now resolved on the server side:
Before: "Input tag 'str' found using kind_of() does not match any of the expected tags: 'LookupSecret', 'StaticSecret'"
After: Plain strings automatically converted to StaticSecret objects ā
The server-side solution is complete and ready for review. This complements the earlier client-side fix (PR #1231) to provide a comprehensive solution for the secrets compatibility issue.
<sub>View full conversation</sub>nutritious-balloon-65098
11/22/2025, 5:38 PMconvert_string_secrets field validator in models.py
⢠Created 7 comprehensive unit tests in test_models.py
⢠Added 2 integration tests in test_conversation_router.py
⢠Fixed discriminator to use correct class names
⢠All tests passing, pre-commit hooks passed
Result:
⢠Before: workspace.update_secrets({"API_KEY": "secret"}) ā ā 422 error
⢠After: workspace.update_secrets({"API_KEY": "secret"}) ā ā
Works automatically
Pull Request: https://github.com/OpenHands/software-agent-sdk/pull/1234
The fix is based on v1.2.0 release, maintains full backward compatibility, and enables natural string usage for secrets.
<sub>View full conversation</sub>