-
Notifications
You must be signed in to change notification settings - Fork 322
feat(integrations): Include case tags in case and metrics UDFs #1817
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| from tracecat.cases.service import CasesService, CaseCommentsService | ||
| from tracecat.db.engine import get_async_session_context_manager | ||
| from tracecat.auth.users import lookup_user_by_email | ||
| from tracecat.cases.tags.schemas import CaseTagRead | ||
| from tracecat.tags.schemas import TagRead, TagCreate | ||
| from tracecat.tables.common import coerce_optional_to_utc_datetime | ||
| from tracecat_registry import registry | ||
|
|
@@ -363,6 +364,10 @@ async def get_case( | |
| ) | ||
| ) | ||
|
|
||
| # Get tags for the case | ||
| tags = await service.tags.list_tags_for_case(case.id) | ||
| tag_reads = [CaseTagRead.model_validate(tag, from_attributes=True) for tag in tags] | ||
|
Comment on lines
+367
to
+369
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After Useful? React with 👍 / 👎. |
||
|
|
||
| # Convert any UUID to string before serializing | ||
| case_read = CaseRead( | ||
| id=case.id, # Use UUID directly | ||
|
|
@@ -376,6 +381,7 @@ async def get_case( | |
| description=case.description, | ||
| fields=final_fields, | ||
| payload=case.payload, | ||
| tags=tag_reads, | ||
| ) | ||
|
|
||
| # Use model_dump(mode="json") to ensure UUIDs are converted to strings | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0: Using
serviceoutside itsasync withcontext manager will cause a runtime error. The database session is closed after theasync with CasesService.with_session() as service:block ends. Move this code inside the context manager block.Prompt for AI agents