Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(drivers-event-listener-griptape-cloud): add type/timestamp fallbacks for custom events #1758

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

collindutter
Copy link
Member

@collindutter collindutter commented Feb 24, 2025

Describe your changes

Problem:

Users can publish custom events by passing a dict to publish_event:

def publish_event(self, event: BaseEvent | dict) -> None:
event_payload = event if isinstance(event, dict) else event.to_dict()

GriptapeCloudEventListenerDriver makes assumptions about what these events will contain:

def _get_event_request(self, event_payload: dict) -> dict:
return {
"payload": event_payload,
"timestamp": event_payload["timestamp"],
"type": event_payload["type"],
}

Solution:

Add fallbacks for these keys:

def _get_event_request(self, event_payload: dict) -> dict:
return {
"payload": event_payload,
"timestamp": event_payload.get("timestamp", time.time()),
"type": event_payload.get("type", "UserEvent"),
}

Issue ticket number and link

NA

@collindutter collindutter added this to the 1.4 milestone Feb 24, 2025
@collindutter collindutter self-assigned this Feb 24, 2025
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@collindutter collindutter added this pull request to the merge queue Feb 24, 2025
Merged via the queue into main with commit ef52194 Feb 24, 2025
16 checks passed
@collindutter collindutter deleted the fix/griptape-cloud-events branch February 24, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants