Skip to content

Conversation

@siddheshbhasme
Copy link

@siddheshbhasme siddheshbhasme commented Feb 8, 2026

Description

Fixes a validation error in ConversationResource when creating conversations without an initial activity.

Problem

The activity_id and service_url field was required in the ConversationResource model but seems they are not returned from the api and thus we keep getting error:

2 validation errors for ConversationResource
activityId
  Field required [type=missing, input_value={'id': 'a:16rb-rgQdOvwJHO...R4QJyKZe6RKmWaqmlWc1ot'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
serviceUrl
  Field required [type=missing, input_value={'id': 'a:16rb-rgQdOvwJHO...R4QJyKZe6RKmWaqmlWc1ot'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing

Seems teams.net already has it adapted - here

Solution

  • Made activity_id and service_url optional (Optional[str] = None) in ConversationResource
  • Updated test mocks to conditionally include activityId based on request content
  • Added test case for creating conversations without activities

Testing

  • Added test_create_conversation_without_activity to verify the fix
  • Added model validation tests
  • Existing test test_create_conversation still validates the activity scenario

The activity_id field in ConversationResource is now optional to match
the actual API behavior. When creating a conversation without an initial
activity, the Teams API does not include activityId in the response,
which was causing validation errors.

Changes:
- Made activity_id Optional[str] with default None in ConversationResource
- Updated mock transport to conditionally include activityId based on request body
- Added test case for creating conversation without activity

Fixes validation error when creating conversations without activities.
@siddheshbhasme
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Collaborator

@lilyydu lilyydu left a comment

Choose a reason for hiding this comment

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

Thank you for catching and filing this! Just a comment about splitting the test cases :)

assert response.service_url is not None

@pytest.mark.asyncio
async def test_conversation_resource_optional_fields(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

please split these into 4 different test cases

Copy link
Author

Choose a reason for hiding this comment

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

sure, made the changes now :)

Copy link
Collaborator

@lilyydu lilyydu left a comment

Choose a reason for hiding this comment

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

Thank you for fixing!

assert response.activity_id is None
assert response.service_url is not None

async def test_conversation_resource_with_all_fields(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

tests seem to be failing b/c these methods are missing @pytest.mark.asyncio

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